Improve dockerfile
This commit is contained in:
parent
247bc8b3af
commit
3579abff01
3 changed files with 4 additions and 42 deletions
|
|
@ -57,9 +57,9 @@ FROM base AS prod-deps
|
|||
RUN pnpm install --frozen-lockfile --prod && pnpm store prune
|
||||
|
||||
# ==============================================================================
|
||||
# Staging stage - For staging environment
|
||||
# Final stage - Production image
|
||||
# ==============================================================================
|
||||
FROM base AS staging
|
||||
FROM base AS final
|
||||
|
||||
# Copy built api application
|
||||
COPY --from=build /app/apps/api/dist ./apps/api/dist
|
||||
|
|
@ -84,43 +84,6 @@ USER nodejs
|
|||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Set staging environment
|
||||
ENV NODE_ENV=staging
|
||||
|
||||
# NODE_ENV will be set via Cloud Run environment variables
|
||||
# Start the application
|
||||
CMD ["pnpm", "start"]
|
||||
|
||||
# ==============================================================================
|
||||
# Production stage - For production environment (default)
|
||||
# ==============================================================================
|
||||
FROM base AS production
|
||||
|
||||
# Copy built api application
|
||||
COPY --from=build /app/apps/api/dist ./apps/api/dist
|
||||
COPY --from=build /app/apps/api/package.json ./apps/api/package.json
|
||||
|
||||
# Copy shared packages (needed for workspace resolution)
|
||||
COPY --from=prod-deps /app/packages ./packages
|
||||
|
||||
# Install production dependencies
|
||||
# This ensures proper symlink structure for pnpm
|
||||
RUN pnpm install --frozen-lockfile --prod --filter @xtablo/api...
|
||||
|
||||
# Set working directory to api app
|
||||
WORKDIR /app/apps/api
|
||||
|
||||
# Change ownership to nodejs user
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER nodejs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Set production environment
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Start the application
|
||||
# no-dd-sa:docker-best-practices/multiple-cmd
|
||||
CMD ["pnpm", "start"]
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
steps:
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: [ 'build', '-f', 'apps/api/Dockerfile', '--target', '$_NODE_ENV', '-t', 'europe-west1-docker.pkg.dev/$_AR_PROJECT_ID/$_AR_REPOSITORY/xtablo-source/$_SERVICE_NAME:$COMMIT_SHA', '.' ]
|
||||
args: [ 'build', '-f', 'apps/api/Dockerfile', '-t', 'europe-west1-docker.pkg.dev/$_AR_PROJECT_ID/$_AR_REPOSITORY/xtablo-source/$_SERVICE_NAME:$COMMIT_SHA', '.' ]
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: ['push', 'europe-west1-docker.pkg.dev/$_AR_PROJECT_ID/$_AR_REPOSITORY/xtablo-source/$_SERVICE_NAME:$COMMIT_SHA']
|
||||
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
"dotenv": "^16.5.0",
|
||||
"glob": "^11.0.3",
|
||||
"googleapis": "^161.0.0",
|
||||
"graphile-worker": "^0.16.6",
|
||||
"hono": "^4.7.7",
|
||||
"hono-sessions": "^0.7.2",
|
||||
"luxon": "^3.7.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue