Dockerfile
FROM node:lts-bullseye-slim
MAINTAINER Shikong <sk@skcks.cn>
ENV TZ Asia/Shanghai
#USER gitlab-runner:gitlab-runner
ENV HOME /opt/dev/
ENV HOME_PATH /opt/dev/
RUN mkdir -p $HOME_PATH
RUN chown -R 999:999 $HOME_PATH
RUN apt-get update && apt-get install -y git
USER 999:999
WORKDIR $HOME_PATH
RUN npm config set registry https://registry.npmmirror.com
CMD ["yarn", "run", "build"]
创建 docker 镜像
docker build -t frontend-package:0.0.1 .
打包命令
docker run -v `pwd`:/opt/dev frontend-package:0.0.1 sh -c 'yarn install;yarn build'
推送到私仓
docker tag frontend-package:0.0.1 myregistry:5000/frontend-package:0.0.1
docker push myregistry:5000/frontend-package:0.0.1
执行命令(示例)
docker run -v `pwd`:/opt/dev myregistry:5000/frontend-package:0.0.1 sh -c 'yarn install;yarn run build'