Skip to content

Instantly share code, notes, and snippets.

@leolord
Created June 21, 2020 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leolord/91fe16a89bfede8e85e5322f2f18350c to your computer and use it in GitHub Desktop.
Save leolord/91fe16a89bfede8e85e5322f2f18350c to your computer and use it in GitHub Desktop.
# 指定一些变量
ARG PROOT=/root/app
ARG APP_PORT=3000
# 指定底包
FROM alpine:latest
LABEL version="1.0"
LABEL description="node docker file based on alpine which is quite small."
LABEL maintainer="leolord(fortomorrow@163.com)"
# 使用阿里云镜像,并安装必须依赖
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk add nginx nodejs npm
RUN echo 'home=https://npm.taobao.org \
registry=https://registry.npm.taobao.org/' > ~/.npmrc
RUN npm install -g yarn
# 当前工作目录
RUN mkdir -p ${PROOT}
WORKDIR ${PROOT}
# 设置环境变量
ENV NODE_ENV production
ENV WORKER 2
# 复制文件
COPY from to
# 安装依赖
RUN yarn
# 指定监听端口
EXPOSE ${APP_PORT}/tcp
EXPOSE ${APP_PORT}/udp
# 启动服务
CMD ["yarn", "run", "dev", "--port=3000"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment