chore: make all the docker stuff work

This commit is contained in:
Mythie
2025-02-14 14:53:01 +11:00
parent 1c4878e526
commit 113ab293bb
7 changed files with 49 additions and 188 deletions

View File

@@ -3,7 +3,16 @@
# Exit on error. # Exit on error.
set -eo pipefail set -eo pipefail
cd "$(dirname "$0")/.." SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
WEB_APP_DIR="$SCRIPT_DIR/.."
# Store the original directory
ORIGINAL_DIR=$(pwd)
# Set up trap to ensure we return to original directory
trap 'cd "$ORIGINAL_DIR"' EXIT
cd "$WEB_APP_DIR"
start_time=$(date +%s) start_time=$(date +%s)

View File

@@ -22,7 +22,7 @@ RUN npm install -g "turbo@^1.9.3"
# Outputs to the /out folder # Outputs to the /out folder
# source: https://turbo.build/repo/docs/reference/command-line-reference/prune#--docker # source: https://turbo.build/repo/docs/reference/command-line-reference/prune#--docker
RUN turbo prune --scope=@documenso/web --docker RUN turbo prune --scope=@documenso/remix --docker
########################### ###########################
# INSTALLER CONTAINER # # INSTALLER CONTAINER #
@@ -72,42 +72,46 @@ COPY turbo.json turbo.json
RUN npm install -g "turbo@^1.9.3" RUN npm install -g "turbo@^1.9.3"
RUN turbo run build --filter=@documenso/web... RUN turbo run build --filter=@documenso/remix...
########################### ###########################
# RUNNER CONTAINER # # RUNNER CONTAINER #
########################### ###########################
FROM base AS runner FROM base AS runner
WORKDIR /app ENV HUSKY 0
ENV DOCKER_OUTPUT 1
# Don't run production as root # Don't run production as root
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nodejs
USER nextjs USER nodejs
COPY --from=installer /app/apps/web/next.config.js . WORKDIR /app
COPY --from=installer /app/apps/web/package.json .
COPY --from=builder --chown=nodejs:nodejs /app/out/json/ .
# Copy the tailwind config files across
COPY --from=builder --chown=nodejs:nodejs /app/out/full/packages/tailwind-config ./packages/tailwind-config
RUN npm ci --only=production
# Automatically leverage output traces to reduce image size # Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing # https://nodejs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ COPY --from=installer --chown=nodejs:nodejs /app/apps/remix/build ./apps/remix/build
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static COPY --from=installer --chown=nodejs:nodejs /app/apps/remix/public ./apps/remix/public
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
# Copy the prisma binary, schema and migrations # Copy the prisma binary, schema and migrations
COPY --from=installer --chown=nextjs:nodejs /app/packages/prisma/schema.prisma ./packages/prisma/schema.prisma COPY --from=installer --chown=nodejs:nodejs /app/packages/prisma/schema.prisma ./packages/prisma/schema.prisma
COPY --from=installer --chown=nextjs:nodejs /app/packages/prisma/migrations ./packages/prisma/migrations COPY --from=installer --chown=nodejs:nodejs /app/packages/prisma/migrations ./packages/prisma/migrations
COPY --from=installer --chown=nextjs:nodejs /app/node_modules/prisma/ ./node_modules/prisma/
COPY --from=installer --chown=nextjs:nodejs /app/node_modules/@prisma/ ./node_modules/@prisma/
# Symlink the prisma binary # Generate the prisma client again
RUN mkdir node_modules/.bin RUN npx prisma generate --schema ./packages/prisma/schema.prisma
RUN ln -s /app/node_modules/prisma/build/index.js ./node_modules/.bin/prisma
# Get the start script from docker/start.sh # Get the start script from docker/start.sh
COPY --chown=nextjs:nodejs ./docker/start.sh ./start.sh COPY --chown=nodejs:nodejs ./docker/start.sh /app/apps/remix/start.sh
WORKDIR /app/apps/remix
CMD ["sh", "start.sh"] CMD ["sh", "start.sh"]

View File

@@ -2,6 +2,6 @@
set -x set -x
npx prisma migrate deploy --schema ./packages/prisma/schema.prisma npx prisma migrate deploy --schema ../../packages/prisma/schema.prisma
HOSTNAME=0.0.0.0 node apps/web/server.js HOSTNAME=0.0.0.0 node build/server/main.js

164
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@
"lint": "turbo run lint", "lint": "turbo run lint",
"lint:fix": "turbo run lint:fix", "lint:fix": "turbo run lint:fix",
"format": "prettier --write \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts,mdx}\"", "format": "prettier --write \"**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts,mdx}\"",
"prepare": "husky install", "prepare": "husky && husky install || true",
"commitlint": "commitlint --edit", "commitlint": "commitlint --edit",
"clean": "turbo run clean && rimraf node_modules", "clean": "turbo run clean && rimraf node_modules",
"d": "npm run dx && npm run dev", "d": "npm run dx && npm run dev",

View File

@@ -17,6 +17,7 @@
"worker:test": "tsup worker/index.ts --format esm" "worker:test": "tsup worker/index.ts --format esm"
}, },
"dependencies": { "dependencies": {
"@documenso/tailwind-config": "*",
"@documenso/nodemailer-resend": "2.0.0", "@documenso/nodemailer-resend": "2.0.0",
"@react-email/body": "0.0.4", "@react-email/body": "0.0.4",
"@react-email/button": "0.0.11", "@react-email/button": "0.0.11",
@@ -40,7 +41,6 @@
"resend": "2.0.0" "resend": "2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@documenso/tailwind-config": "*",
"@documenso/tsconfig": "*", "@documenso/tsconfig": "*",
"@types/nodemailer": "^6.4.14", "@types/nodemailer": "^6.4.14",
"tsup": "^7.1.0" "tsup": "^7.1.0"

View File

@@ -25,15 +25,15 @@
"kysely": "0.26.3", "kysely": "0.26.3",
"prisma": "^5.4.2", "prisma": "^5.4.2",
"prisma-extension-kysely": "^2.1.0", "prisma-extension-kysely": "^2.1.0",
"ts-pattern": "^5.0.6" "prisma-kysely": "^1.8.0",
"prisma-json-types-generator": "^3.2.2",
"ts-pattern": "^5.0.6",
"zod-prisma-types": "3.1.9"
}, },
"devDependencies": { "devDependencies": {
"dotenv": "^16.3.1", "dotenv": "^16.3.1",
"dotenv-cli": "^7.3.0", "dotenv-cli": "^7.3.0",
"prisma-json-types-generator": "^3.2.2",
"prisma-kysely": "^1.8.0",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "5.6.2", "typescript": "5.6.2"
"zod-prisma-types": "3.1.9"
} }
} }