prepare for production

This commit is contained in:
Patrick 2025-04-20 22:35:46 +02:00
parent e18adab888
commit 888e35f839
4 changed files with 83 additions and 0 deletions

16
.dockerignore Normal file
View File

@ -0,0 +1,16 @@
node_modules
Dockerfile*
.dockerignore
.git
.gitignore
README.md
LICENSE
databases
docs
documents
pdfgen
!pdfgen/template-*
scripts
tmp-user-data
user-data

49
Dockerfile Normal file
View File

@ -0,0 +1,49 @@
FROM oven/bun:alpine AS base
WORKDIR /usr/src/app
ENV NODE_ENV=production
ENV APP_USER_DATA_PATH="/app-data/user-data"
ENV APP_TMP_USER_DATA_PATH="/app-data/tmp"
## Stage 1: Install dependencies
FROM base AS install
# install development dependencies
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
# install production dependencies
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
## Stage 2: Build app
FROM base AS prerelease
# copy dependencies into workdir
COPY --from=install /temp/dev/node_modules node_modules
# add project files
COPY . .
# build project
RUN bun run build
## Stage 3: Put everything together
FROM base AS release
# compose the final image
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/build .
#COPY --from=prerelease /usr/src/app/package.json .
RUN mkdir /app-data && chown bun:bun /app-data
VOLUME ["/app-data"]
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "--bun", "run", "start" ]

View File

@ -0,0 +1,3 @@
services:
application:
build: .

15
docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
name: Stundenaufzeichnung
volumes:
user-data:
services:
application:
build: https://git.maschek.info/patrick/stundenaufzeichnung.git#main
ports:
- 3000:3000
volumes:
- type: volume
source: user-data
target: /app-data