From 4bdaa8306e1a49c4489e894a355b987f1a1067f2 Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Wed, 29 Nov 2023 07:03:54 -0500 Subject: [PATCH] Build on-the-metal --- .dockerignore | 3 --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++++++++- Dockerfile | 2 ++ dist.Dockerfile | 8 ++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 dist.Dockerfile diff --git a/.dockerignore b/.dockerignore index 10a3a94..a64751a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,9 +8,6 @@ pnpm-debug.log* lerna-debug.log* node_modules -dist -dist-ssr -*.local /data diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87e6d8f..d2e16d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,37 @@ jobs: runs-on: ubuntu-22.04 steps: + - name: Git checkout + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 21 + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false + - name: Get pnpm store directory + id: pnpm + shell: bash + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Test + run: pnpm run test + - name: Build + run: pnpm run build + - name: Decide image tags id: info shell: python @@ -78,7 +109,7 @@ jobs: if: (github.event_name == 'push' || github.event_name == 'release') with: context: . - file: ./Dockerfile + file: ./dist.Dockerfile tags: ${{ steps.info.outputs.tags_csv }} platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7,linux/ppc64le push: ${{ steps.info.outputs.push }} diff --git a/Dockerfile b/Dockerfile index 0cf5d52..e9d6f68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# Build in Docker + FROM docker.io/library/node:21.2.0-alpine3.18 AS build # See https://pnpm.io/docker diff --git a/dist.Dockerfile b/dist.Dockerfile new file mode 100644 index 0000000..72a3d86 --- /dev/null +++ b/dist.Dockerfile @@ -0,0 +1,8 @@ +# Build on-the-metal, deploy using Docker + +FROM docker.io/library/caddy:2.7.5-alpine +COPY ./Caddyfile /etc/caddy/Caddyfile +COPY ./dist /app/dist + +EXPOSE 2019 8080 +CMD ["caddy", "run", "-c", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]