Last active
December 21, 2023 20:21
-
-
Save esamattis/bb82b149813aa8725d0e81892143b0d5 to your computer and use it in GitHub Desktop.
How to deploy a single app to a container from a pnpm monorepo using `pnpm deploy` in Github Actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy myapp as a container | |
jobs: | |
deploy-myapp: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- uses: pnpm/[email protected] | |
with: | |
version: 7.9.5 | |
- name: Set pnpm store path | |
run: echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV | |
- name: Cache pnpm modules | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.PNPM_STORE_PATH }} | |
key: pnpm-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
pnpm-${{ runner.os }}- | |
- name: Cache turborepo | |
uses: actions/cache@v2 | |
with: | |
path: node_modules/.cache/turbo/ | |
key: turbo-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
turbo-${{ runner.os }}- | |
- name: Install node modules only for the root package and myapp | |
run: pnpm install --filter root --filter myapp | |
# Turborepo is installed to the workspace root which is why | |
# we need to install root deps as well | |
- name: Build myapp only with Turborepo | |
run: ./node_modules/.bin/turbo run build --filter myapp | |
- name: Run pnpm deploy | |
run: pnpm deploy --filter myapp pnpm-deploy-output | |
- name: Authenticate to the Container Registry | |
run: XXX | |
- name: Build the container and push it to Container Registry | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: packages/myapp/Dockerfile | |
push: true | |
tags: XXX | |
- name: Deploy the container | |
run: XXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:14-slim | |
ENV NODE_ENV=production | |
COPY pnpm-deploy-output /app | |
WORKDIR /app | |
ENTRYPOINT ["/app/entrypoint.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Clee681 It's just
But the
node_modules/.bin
usage might be broken inside the container because the file system paths are different on GH Actions and the container. So invoke your app directly.