Skip to content

Commit

Permalink
Migrate to monorepo deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Sep 7, 2024
1 parent d45a0ad commit 92b4962
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 369 deletions.
101 changes: 0 additions & 101 deletions .github/workflows/deploy-ducksmanager.yml

This file was deleted.

110 changes: 0 additions & 110 deletions .github/workflows/deploy-edgecreator.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: deploy

on:
workflow_dispatch:
push:
branches:
- "legacy"
jobs:
build:
runs-on: ubuntu-latest
environment: production
env:
REMOTE_ROOT: workspace/DucksManager2
PRODUCTION_SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }}
PRODUCTION_SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }}
PRODUCTION_SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }}
name: deploy
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: bperel
password: ${{ secrets.DOCKER_REGISTRY_TOKEN_DM }}

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.8.0

- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: |
pnpm -r i
- name: Build apps
run: |
pnpm i -g turbo
turbo -F '~web...' -F '~api...' build
- name: Retrieve pre-build files
run: |
turbo -F '~web...' -F '~api...' prod:transfer-files-pre
- uses: docker/setup-buildx-action@v3

- name: Build and push Docker images
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
turbo -F -F '~web...' -F '~api...' prod:build-docker
- name: Send post-build files
run: |
turbo -F '~web...' -F '~api...' prod:transfer-files-post
- name: Deploy
run: |
turbo -F '~web...' -F '~api...' prod:deploy
1 change: 1 addition & 0 deletions apps/duck-estimator/duck-estimator-db
Submodule duck-estimator-db added at 2aa53c
51 changes: 2 additions & 49 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,5 @@
FROM node:18.20 AS pnpm

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM pnpm AS build

WORKDIR /app
COPY . ./
RUN curl -fsSL https://bun.sh/install | bash
RUN --mount=type=cache,id=pnpm-store-web,target=/app/.pnpm-store \
pnpm -r -F ~web... -F ~api... i

RUN pnpm -r -F ~web... -F ~api... run build

FROM nginx AS web
FROM nginx
LABEL org.opencontainers.image.authors="Bruno Perel"

COPY apps/web/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/apps/web/dist /usr/share/nginx/html


FROM pnpm AS api
LABEL org.opencontainers.image.authors="Bruno Perel"

WORKDIR /app

COPY package.json ./
COPY pnpm-*.yaml ./

COPY --from=build /app/packages/prisma-clients ./packages/prisma-clients
COPY --from=build /app/packages/types ./packages/types
COPY --from=build /app/packages/prisma-clients/dist/ ./packages/prisma-clients
COPY --from=build /app/packages/types/dist/ ./packages/types
COPY --from=build /app/packages/api/dist/api ./packages/api

COPY packages/api/package.json ./packages/api
COPY packages/api/translations ./packages/api/translations
COPY packages/api/emails ./packages/api/emails
COPY packages/api/scripts ./packages/api/scripts

RUN --mount=type=cache,id=pnpm-store,target=/app/.pnpm-store \
pnpm i --production

COPY ./packages/api/routes/demo/*.csv ./routes/demo/
COPY ./packages/api/emails ./emails/
COPY ./packages/api/.env ./.env

EXPOSE 3000

CMD ["node", "packages/api/index.js"]
COPY apps/web/dist /usr/share/nginx/html
Loading

0 comments on commit 92b4962

Please sign in to comment.