就此而言,我是 Kubernetes(和 Docker)的新手。我需要了解使用 Devspace 迁移现有 Vue.js 应用程序的过程。我的应用程序正在运行,有点像,但我没有连接到
ws://localhost:4000/graphql
或者能够建立一个mongo连接。
MongoServerSelectionError:连接 ECONNREFUSED 127.0.0.1:27017
相关的预先存在的 package.json 入口点
"serve": "vue-cli-service serve -mode development",
"build": "vue-cli-service build",
"apollo": "vue-cli-service apollo:dev --generate-schema",
"apollo:schema:generate": "vue-cli-service apollo:schema:generate",
"apollo:schema:publish": "vue-cli-service apollo:schema:publish",
"apollo:start": "vue-cli-service apollo:start",
应用结构
/apollo-server
context.js ## Mongo connection made here.
/src
vue-apollo.js ## Apollo setup (Graphql is setup here.)
Dockerfile
devspace.yaml
package.json
现在,
Dockerfile
FROM node:13.12.0-alpine
# Set working directory
WORKDIR /app
# Add package.json to WORKDIR and install dependencies
COPY package*.json ./
RUN npm install
# Add source code files to WORKDIR
COPY . .
# Application port (optional)
# express server runs on port 3000
EXPOSE 3000
# Debugging port (optional)
# For remote debugging, add this port to devspace.yaml: dev.ports[*].forward[*].port: 9229
EXPOSE 9229
CMD ["npm", "start"]
开发空间.yaml
version: v1beta9
images:
app:
image: sandbox/practiceapp
preferSyncOverRebuild: true
injectRestartHelper: false
cmd: ["yarn", "serve"]
appendDockerfileInstructions:
- USER root
backend:
image: sandbox/backend
preferSyncOverRebuild: true
injectRestartHelper: false
entrypoint: ["yarn", "apollo"]
appendDockerfileInstructions:
- USER root
deployments:
- name: frontend
helm:
componentChart: true
values:
containers:
- image: sandbox/practiceapp
service:
ports:
- port: 8080
- name: backend
helm:
componentChart: true
values:
containers:
- image: sandbox/backend
service:
ports:
- port: 4000
- port: 3000
- port: 27017
# - name: mongo
# helm:
# componentChart: true
# values:
# containers:
# - image: sandbox/mongo
# service:
# ports:
# - port: 27017
dev:
ports:
- imageName: app
forward:
- port: 8080
# - imageName: apollo
# forward:
# port: 3000
# - imageName: graphql
# forward:
# port: 4000
# - imageName: mongo
# forward:
# port: 27017
open:
- url: http://localhost:8080
- url: http://localhost:4000/graphql
sync:
- imageName: app
excludePaths:
- .git/
uploadExcludePaths:
- Dockerfile
- node_modules/*
- '!node_modules/.temp/'
- devspace.yaml
onUpload:
restartContainer: true
profiles:
- name: production
patches:
- op: remove
path: images.app.injectRestartHelper
- op: remove
path: images.app.appendDockerfileInstructions
- name: interactive
patches:
- op: add
path: dev.interactive
value:
defaultEnabled: true
- op: add
path: images.app.entrypoint
value:
- sleep
- "9999999999"
我一直在寻找有关如何包含来自预先存在的应用程序的服务的信息,但我很难理解。我需要一些关于如何设置或在哪里查看的指导。
感谢您的帮助和时间。