chore: add development docker environment

adds a docker environment for development.
can be started using:
`docker compose -f docker-compose.dev.yml up --watch --build`
This commit is contained in:
Dominik 2025-05-21 14:29:00 +02:00 committed by Dominik
parent cdc0e81e51
commit a2a5eee49e
4 changed files with 56 additions and 1 deletions

17
Dockerfile.dev Normal file
View file

@ -0,0 +1,17 @@
FROM node:22-alpine@sha256:152270cd4bd094d216a84cbc3c5eb1791afb05af00b811e2f0f04bdc6c473602
WORKDIR /app
RUN corepack enable
COPY package.json yarn.lock .yarnrc.yml ./
RUN yarn install --frozen-lockfile
COPY . .
ENV NODE_ENV=development
ENV NEXT_TELEMETRY_DISABLED=1
EXPOSE 3000
ENV HOSTNAME="0.0.0.0"
CMD ["/bin/ash", "entrypoint.dev.sh"]

27
docker-compose.dev.yml Normal file
View file

@ -0,0 +1,27 @@
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- '3000:3000'
environment:
- AUTH_SECRET=secret
- AUTH_URL=http://localhost:3000
- DATABASE_URL=file:/data/db.sqlite
env_file:
- .env.local
volumes:
- ./data:/data
develop:
watch:
- action: sync
path: ./src
target: /app/src
ignore:
- node_modules/
- action: rebuild
path: package.json
- action: sync+restart
path: prisma
target: /app/prisma

10
entrypoint.dev.sh Normal file
View file

@ -0,0 +1,10 @@
#!/bin/bash
echo "Running start script with user $(whoami) and NODE_ENV $NODE_ENV"
if [ -d "prisma" ]; then
echo "Syncing Prisma database"
yarn prisma:generate
yarn prisma:db:push
fi
exec yarn dev

View file

@ -12,7 +12,8 @@
"prisma:generate": "dotenv -e .env.local -- prisma generate",
"prisma:studio": "dotenv -e .env.local -- prisma studio",
"prisma:db:push": "dotenv -e .env.local -- prisma db push",
"prisma:migrate:reset": "dotenv -e .env.local -- prisma migrate reset"
"prisma:migrate:reset": "dotenv -e .env.local -- prisma migrate reset",
"dev_container": "docker compose -f docker-compose.dev.yml up --watch --build"
},
"dependencies": {
"@auth/prisma-adapter": "^2.9.1",