docker -v
/usr/local/bin/docker-compose -v
cd /opt/front_docker
/usr/local/bin/docker-compose -f build-compose.yml run build-sf-shop-front
/usr/local/bin/docker-compose -f docker-compose.yml build sf-shop-front
build-compose.yml
version: '3.9' #与docker版本
services:
build-sf-shop-front: #服务名
image: node:12-alpine
environment:
- "TZ=Asia/Shanghai"
volumes:
- npm-cache-volume:/cache
- /var/lib/jenkins/workspace/mit-sf-shop-front:/workspace:cached #git代码的路径
ulimits:
nproc: 65535
nofile:
soft: 50000
hard: 50000
command: >
/bin/sh -c "
cd /workspace &&
npm --registry=https://registry.npm.taobao.org i -g node-gyp &&
npm
--cache=/cache
--registry=https://registry.npm.taobao.org
--prefer-offline=true
--package-lock=false
install &&
npm run build:pre" # 运行的环境
build-sf-cms-front:
image: node:12-alpine
environment:
- "TZ=Asia/Shanghai"
volumes:
- npm-cache-volume:/cache
- /var/lib/jenkins/workspace/sf-cms-front-docker:/workspace:cached
ulimits:
nproc: 65535
nofile:
soft: 50000
hard: 50000
command: >
/bin/sh -c "
cd /workspace &&
npm
--cache=/cache
--registry=https://registry.npm.taobao.org
--prefer-offline=true
--package-lock=false
install &&
npm run build:pre"
build-sf-buyer-seller-front:
image: node:12-alpine
environment:
- "TZ=Asia/Shanghai"
volumes:
- npm-cache-volume:/cache
- /var/lib/jenkins/workspace/sf-buyer-seller-front-docker:/workspace:cached
ulimits:
nproc: 65535
nofile:
soft: 50000
hard: 50000
command: >
/bin/sh -c "
cd /workspace &&
npm
--cache=/cache
--registry=https://registry.npm.taobao.org
--prefer-offline=true
--package-lock=false
install &&
npm run build:pre"
build-sf-erp-front:
image: node:12-alpine
environment:
- "TZ=Asia/Shanghai"
volumes:
- npm-cache-volume:/cache
- /opt/front_docker/workspace/erp:/workspace:cached
ulimits:
nproc: 65535
nofile:
soft: 50000
hard: 50000
command: >
/bin/sh -c "
cd /workspace &&
npm
--cache=/cache
--registry=https://registry.npm.taobao.org
--prefer-offline=true
--package-lock=false
install &&
npm run build:pre"
build-sany-wx-h5:
image: node:12-alpine
environment:
- "TZ=Asia/Shanghai"
volumes:
- npm-cache-volume:/cache
- ./sany-wx-h5:/workspace:cached
ulimits:
nproc: 65535
nofile:
soft: 50000
hard: 50000
volumes:
maven-cache-volume:
name: maven-cache
npm-cache-volume:
name: npm-cache
yarn-cache-volume:
name: yarn-cache
docker-compose.yml
version: '3.8'
services:
sf-erp-front:
build:
context: /opt/front_docker/workspace/erp
image: /31scm/commerce:sf-erp-front_latest
container_name: sf-erp-front
environment:
- "TZ=Asia/Shanghai"
- "SERVER_PORT=8080"
ports:
- "8080:8080"
restart: on-failure
networks:
- "backend"
sf-shop-front:
build:
context: /var/lib/jenkins/workspace/mit-sf-shop-front
image: /31scm/commerce:sf-shop-front_latest
container_name: sf-shop-front
environment:
- "TZ=Asia/Shanghai"
- "SERVER_PORT=9009"
ports:
- "8000:9009"
restart: on-failure
networks:
- "backend"
sf-buyer-seller-front:
build:
context: /opt/front_docker/workspace/buyer
image: /31scm/commerce:sf-buyer-front_latest
container_name: sf-buyer-front
environment:
- "TZ=Asia/Shanghai"
- "SERVER_PORT=8081"
- "SHOPPING_URI=localhost:8000"
- "HELP_URI=localhost:8082"
- "BUYER_URI=localhost:8081"
ports:
- "8081:8081"
restart: on-failure
networks:
- "backend"
sf-cms-front:
build:
context: /opt/front_docker/workspace/cms
image: /31scm/commerce:sf-cms-front_latest
container_name: sf-cms-front
environment:
- "TZ=Asia/Shanghai"
- "SERVER_PORT=8082"
ports:
- "8082:8082"
restart: on-failure
networks:
- "backend"
#sany-wx-h5:
# build:
# context: /opt/front_docker/workspace/erp
# image: xunkutech/sany-wx-h5:${COMMIT}
# container_name: sany-wx-h5
# environment:
# - "TZ=Asia/Shanghai"
# - "SERVER_PORT=8083"
# ports:
# - "8083:8083"
# restart: on-failure
# networks:
# - "backend"
networks:
backend:
driver: bridge
服务端渲染的dockerfile
FROM hub.c.163.com/netease_comb/centos:7
COPY ./.nuxt /www/.nuxt
COPY ./node_modules /www/node_modules
COPY ./static /www/static
COPY ./nuxt.config.js /www/nuxt.config.js
COPY ./package.json /www/package.json
RUN yum makecache fast && yum install epel-release -y
RUN rm -f /etc/localtime && ln -s ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN yum install nodejs -y
RUN yum install openssl -y
RUN yum install gettext -y
RUN npm i -g n && n 12.16.0 stable
RUN npm i -g pm2
RUN yum install nginx -y
COPY default.conf.template /etc/nginx/templates/default.conf.template
WORKDIR /www
ENTRYPOINT envsubst '$SERVER_PORT' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf && \
/usr/sbin/nginx && pm2 start --no-daemon npm --name sany-buyer-front -- run start --watch
# ENTRYPOINT ["sh", "-c" ,"pm2 start --no-daemon npm --name sany-buyer-front -- run start --watch"]
普通的vue项目的dockerfile
FROM nginx:1.21.3-alpine
COPY dist /www
COPY default.conf.template /etc/nginx/templates/default.conf.template
RUN rm -f /etc/localtime && ln -s ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime
















