myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 586f9e2185ac99277323f58a698969826a946971
parent 51dbf24abf56f12e487309da60300bb324755228
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun, 20 Oct 2024 12:00:58 +0200

feat: add dockerfiles

Diffstat:
Adockerfiles/api/Dockerfile | 14++++++++++++++
Adockerfiles/frontend/Dockerfile | 38++++++++++++++++++++++++++++++++++++++
Adockerfiles/frontend/myheats.conf | 8++++++++
3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/dockerfiles/api/Dockerfile b/dockerfiles/api/Dockerfile @@ -0,0 +1,14 @@ +FROM docker.io/node:18-alpine + +RUN apk update +RUN apk add --no-cache git + +WORKDIR /app +RUN git clone --depth 1 https://git.in0rdr.ch/myheats.git /app + +RUN npm ci + +ENV NODE_ENV production + +# run nodejs api/backend server +CMD [ "npm", "run", "api" ] diff --git a/dockerfiles/frontend/Dockerfile b/dockerfiles/frontend/Dockerfile @@ -0,0 +1,38 @@ +FROM docker.io/node:18-alpine AS builder + +# use NODE_ENV=prod to exclude the `devDependencies` (e..g, vite) +# we require `vite` command in `npm run build` below +ARG NODE_ENV=dev + +# Read args from build command +ARG VITE_APP_DOC_TITLE='My Heats' + +# Configure the env with the args +ENV NODE_ENV="$NODE_ENV" +ENV VITE_APP_DOC_TITLE="$VITE_APP_DOC_TITLE" + +RUN apk update +RUN apk add --no-cache git + +WORKDIR /app +RUN git clone --depth 1 https://git.in0rdr.ch/myheats.git /app + +# install npm dependencies to node_modules +# https://docs.npmjs.com/cli/v10/commands/npm-ci +RUN npm ci + +# vite static build (for production) +# https://vitejs.dev/guide/build +RUN npm run build + +FROM docker.io/nginx:alpine + +# install the static files +RUN rm -rf /usr/share/nginx/html/* +COPY --from=builder /app/dist/ /usr/share/nginx/html/ + +# install config file +RUN rm -rf /etc/nginx/conf.d/* +COPY myheats.conf /etc/nginx/conf.d/ + +CMD ["nginx", "-g", "daemon off;"] diff --git a/dockerfiles/frontend/myheats.conf b/dockerfiles/frontend/myheats.conf @@ -0,0 +1,8 @@ +server { + listen 80; + + location / { + root /usr/share/nginx/html; + try_files $uri /index.html; + } +}