Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}

- name: Set up QEMU
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand Down
34 changes: 9 additions & 25 deletions deployment/prod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Stage 1: Build the SvelteKit application and scheduler
FROM node:22-alpine AS builder
FROM --platform=linux/amd64 node:22-bullseye-slim AS builder

WORKDIR /app

Expand Down Expand Up @@ -29,11 +29,11 @@ WORKDIR /app/packages/scheduler
RUN npm run build

# Stage 2: Production environment
FROM node:22-alpine
FROM --platform=$TARGETPLATFORM node:22-bullseye-slim

# Create a non-root user and group
RUN addgroup -g 1001 -S nodejs && \
adduser -S app -u 1001 -G nodejs
# Create a non-root user and group (Debian syntax)
RUN groupadd -g 1001 nodejs && \
useradd -r -u 1001 -g nodejs app

WORKDIR /app

Expand All @@ -44,24 +44,16 @@ COPY packages/simply-tweeted-app/package.json ./packages/simply-tweeted-app/
COPY packages/shared-lib/package.json ./packages/shared-lib/
COPY packages/scheduler/package.json ./packages/scheduler/

# Install concurrently for running multiple services
RUN npm install concurrently

# Copy built shared-lib from builder stage
COPY --from=builder /app/packages/shared-lib/dist ./packages/shared-lib/dist
COPY --from=builder /app/packages/shared-lib/package.json ./packages/shared-lib/
# Copy built app from builder stage
COPY --from=builder /app/packages/simply-tweeted-app/build ./packages/simply-tweeted-app/build
# Copy built scheduler from builder stage
COPY --from=builder /app/packages/scheduler/dist ./packages/scheduler/dist

# Copy scheduler source files (needed for any runtime dependencies)
COPY packages/scheduler/src ./packages/scheduler/src

# Install production dependencies only
RUN npm ci --omit=dev

# Install concurrently globally for easier access
RUN npm install -g concurrently
# Install production dependencies and concurrently
RUN npm ci --omit=dev && npm install -g concurrently

# Change ownership of the app directory to the non-root user
RUN chown -R app:nodejs /app
Expand All @@ -72,16 +64,8 @@ USER app
# Expose the port the app will run on
EXPOSE 3000

# Environment variables will be passed at runtime
# ENV AUTH_SECRET=your_auth_secret_value
# ENV DB_ENCRYPTION_KEY=your_db_encryption_key_value
# ENV AUTH_TWITTER_ID=your_auth_twitter_id_value
# ENV AUTH_TWITTER_SECRET=your_auth_twitter_secret_value
# ENV ALLOWED_TWITTER_ACCOUNTS=your_allowed_twitter_accounts_value
# ENV MONGODB_URI=your_mongodb_uri_value

ENV NODE_ENV=production
ENV AUTH_TRUST_HOST=true

# Run both the frontend and scheduler using concurrently
CMD ["concurrently", "--names", "FRONTEND,SCHEDULER", "--prefix-colors", "blue,green", "cd packages/simply-tweeted-app && node build/index.js", "cd packages/scheduler && node dist/index.js"]
CMD ["concurrently", "--names", "FRONTEND,SCHEDULER", "--prefix-colors", "blue,green", "node packages/simply-tweeted-app/build/index.js", "node packages/scheduler/dist/index.js"]