feat: better docker builds

This commit is contained in:
Huskydog9988
2025-05-10 17:27:39 -04:00
parent fc74738643
commit 1bbdf46a0e
4 changed files with 38 additions and 28 deletions

View File

@ -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

View File

@ -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"]
CMD ["sh", "/app/startup/launch.sh"]

View File

@ -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

View File

@ -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