diff --git a/.dockerignore b/.dockerignore index 4abae2b..4078721 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,7 @@ dist # Node dependencies node_modules +.yarn # Logs logs @@ -23,4 +24,8 @@ logs .env.* !.env.example -.data +# deploy template +deploy-template/ + +# generated prisma client +/prisma/client diff --git a/Dockerfile b/Dockerfile index 128e0d0..73ba58f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,40 @@ -# pull pre-configured and updated build environment -FROM debian:testing-20250317-slim AS build-system +# Unified deps builder +FROM node:lts-alpine AS deps +WORKDIR /app +COPY package.json yarn.lock ./ +RUN yarn install --network-timeout 1000000 --ignore-scripts +# Build for app +FROM node:lts-alpine AS build-system # setup workdir - has to be the same filepath as app because fuckin' Prisma WORKDIR /app -# install dependencies and build -RUN apt-get update -y -RUN apt-get install node-corepack -y -RUN corepack enable +ENV NODE_ENV=production +ENV NUXT_TELEMETRY_DISABLED=1 + +# copy deps and rest of project files +COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN NUXT_TELEMETRY_DISABLED=1 yarn install --network-timeout 1000000 -RUN NUXT_TELEMETRY_DISABLED=1 yarn prisma generate -RUN NUXT_TELEMETRY_DISABLED=1 yarn build + +# build +RUN yarn postinstall +RUN yarn build # create run environment for Drop -FROM node:lts-slim AS run-system - +FROM node:lts-alpine AS run-system WORKDIR /app +ENV NODE_ENV=production +ENV NUXT_TELEMETRY_DISABLED=1 + +RUN yarn add --network-timeout 1000000 --no-lockfile prisma@6.7.0 + +COPY --from=build-system /app/package.json ./ COPY --from=build-system /app/.output ./app COPY --from=build-system /app/prisma ./prisma -COPY --from=build-system /app/package.json ./ COPY --from=build-system /app/build ./startup -# OpenSSL as a dependency for Drop (TODO: seperate build environment) -RUN apt-get update -y && apt-get install -y openssl -RUN yarn global add prisma@6.7.0 +ENV LIBRARY="/library" +ENV DATA="/data" -CMD ["/app/startup/launch.sh"] \ No newline at end of file +CMD ["sh", "/app/startup/launch.sh"] diff --git a/build/launch.sh b/build/launch.sh index 0925938..173b311 100755 --- a/build/launch.sh +++ b/build/launch.sh @@ -2,8 +2,7 @@ # This file starts up the Drop server by running migrations and then starting the executable echo "[Drop] performing migrations..." -ls ./prisma/migrations/ -prisma migrate deploy +yarn prisma migrate deploy # Actually start the application -node /app/app/server/index.mjs \ No newline at end of file +node /app/app/server/index.mjs diff --git a/deploy-template/compose.yml b/deploy-template/compose.yml index d3011a6..5573191 100644 --- a/deploy-template/compose.yml +++ b/deploy-template/compose.yml @@ -1,6 +1,7 @@ services: postgres: - image: postgres:14-alpine + # using alpine image to reduce image size + image: postgres:alpine ports: - 5432:5432 healthcheck: @@ -16,7 +17,7 @@ services: - POSTGRES_USER=drop - POSTGRES_DB=drop drop: - image: registry.deepcore.dev/drop-oss/drop/main:latest + image: ghcr.io/drop-oss/drop depends_on: postgres: condition: service_healthy @@ -24,11 +25,6 @@ services: - 3000:3000 volumes: - ./library:/library - - ./certs:/certs - - ./objects:/objects + - ./data:/data environment: - DATABASE_URL=postgres://drop:drop@postgres:5432/drop - - FS_BACKEND_PATH=/objects - - CLIENT_CERTIFICATES=/certs - - LIBRARY=/library - - GIANT_BOMB_API_KEY=REPLACE_WITH_YOUR_KEY