Dockerfile (1332B)
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 ARG VITE_SESSION_TTL=259200 #72h 10 ARG VITE_API_URI=https://api-myheats-demo.p0c.ch 11 ARG VITE_API_PORT=443 12 ARG VITE_WS_URI=wss://api-myheats-demo.p0c.ch 13 ARG VITE_WS_PORT=443 14 ARG VITE_LOCALE=de-CH 15 16 # Configure the env with the args 17 ENV VITE_APP_DOC_TITLE="$VITE_APP_DOC_TITLE" 18 ENV NODE_ENV="$NODE_ENV" 19 ENV VITE_SESSION_TTL="$VITE_SESSION_TTL" 20 ENV VITE_API_URI="$VITE_API_URI" 21 ENV VITE_API_PORT="$VITE_API_PORT" 22 ENV VITE_WS_URI="$VITE_WS_URI" 23 ENV VITE_WS_PORT="$VITE_WS_PORT" 24 ENV VITE_LOCALE="$VITE_LOCALE" 25 26 RUN apk update 27 RUN apk add --no-cache git 28 29 WORKDIR /app 30 RUN git clone --depth 1 https://git.in0rdr.ch/myheats.git /app 31 32 # install npm dependencies to node_modules 33 # https://docs.npmjs.com/cli/v10/commands/npm-ci 34 RUN npm ci 35 36 # vite static build (for production) 37 # https://vitejs.dev/guide/build 38 RUN npm run build 39 40 FROM docker.io/nginx:alpine 41 42 # install the static files 43 RUN rm -rf /usr/share/nginx/html/* 44 COPY --from=builder /app/dist/ /usr/share/nginx/html/ 45 46 # install config file 47 RUN rm -rf /etc/nginx/conf.d/* 48 COPY myheats.conf /etc/nginx/conf.d/ 49 50 CMD ["nginx", "-g", "daemon off;"]