Dockerfile (935B)
1 FROM docker.io/node:18-alpine AS builder 2 3 # use NODE_ENV=prod to exclude the `devDependencies` (e..g, vite) 4 # we require `vite` command in `npm run build` below 5 ARG NODE_ENV=dev 6 7 # Read args from build command 8 ARG VITE_APP_DOC_TITLE='My Heats' 9 10 # Configure the env with the args 11 ENV NODE_ENV="$NODE_ENV" 12 ENV VITE_APP_DOC_TITLE="$VITE_APP_DOC_TITLE" 13 14 RUN apk update 15 RUN apk add --no-cache git 16 17 WORKDIR /app 18 RUN git clone --depth 1 https://git.in0rdr.ch/myheats.git /app 19 20 # install npm dependencies to node_modules 21 # https://docs.npmjs.com/cli/v10/commands/npm-ci 22 RUN npm ci 23 24 # vite static build (for production) 25 # https://vitejs.dev/guide/build 26 RUN npm run build 27 28 FROM docker.io/nginx:alpine 29 30 # install the static files 31 RUN rm -rf /usr/share/nginx/html/* 32 COPY --from=builder /app/dist/ /usr/share/nginx/html/ 33 34 # install config file 35 RUN rm -rf /etc/nginx/conf.d/* 36 COPY myheats.conf /etc/nginx/conf.d/ 37 38 CMD ["nginx", "-g", "daemon off;"]