Skip to content

Commit

Permalink
chore(CI): Include migration deployment in API deploy pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdip-b committed Jul 11, 2024
1 parent f057445 commit dbd5222
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/workflows/deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:${GITHUB_SHA::6}
echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:latest" >> $GITHUB_OUTPUT
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.2.0
run_install: false

- name: Deploy migrations
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
run: pnpm db:deploy-migrations

- name: Force re-deploy task in service
id: force-redeploy
env:
Expand Down
57 changes: 57 additions & 0 deletions apps/platform/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM node:20-alpine AS base


FROM base AS builder
RUN apk add --no-cache libc6-compat
RUN apk update && apk upgrade
# working directory
WORKDIR /app
RUN npm install --ignore-scripts -g turbo
COPY . .
RUN turbo prune platform --docker

# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app

# install the dependencies
RUN npm install --ignore-scripts -g pnpm
COPY .gitignore .gitignore
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --no-cache --ignore-scripts

# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json


RUN pnpm turbo build --filter=platform...

FROM base AS runner
WORKDIR /app

# Don't run production as root
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
USER nextjs

COPY --from=installer /app/apps/platform/next.config.mjs .
COPY --from=installer /app/apps/platform/package.json .

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/platform/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/platform/.next/static ./apps/platform/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/platform/public ./apps/platform/public


ENV PORT=3025
ENV NEXT_SHARP_PATH=/app/apps/platform/.next/sharp
EXPOSE 3025
ENV HOSTNAME "0.0.0.0"


CMD node apps/platform/server.js
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
"docker:run:web": "docker run --env-file .env --name ks-web --rm -p 3000:3000 ks-web",
"docker:build:web": "docker build -t ks-web -f apps/web/Dockerfile .",
"docker:run:api": "docker run --env-file .env --name ks-api --rm -p 4200:4200 ks-api",
"docker:build:api": "docker build -t ks-api -f apps/api/Dockerfile ."
"docker:build:api": "docker build -t ks-api -f apps/api/Dockerfile .",
"docker:run:platform": "docker run --env-file .env --name ks-platform --rm -p 3025:3025 ks-platform",
"docker:build:platform": "docker build -t ks-platform -f apps/platform/Dockerfile ."
},
"devDependencies": {
"@sentry/cli": "^2.28.6",
Expand Down

0 comments on commit dbd5222

Please sign in to comment.