From e16da180aa08c413b1269797cb35975082d24659 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Tue, 25 Jun 2024 16:18:48 +0200 Subject: [PATCH] feat: added image with nodejs20 (#27) --- .github/workflows/publish.yml | 16 ++++++++++++- Dockerfile => 18.Dockerfile | 0 20.Dockerfile | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) rename Dockerfile => 18.Dockerfile (100%) create mode 100644 20.Dockerfile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f16ec53..49f7b07 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -44,6 +44,19 @@ jobs: with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and publish to Docker Hub + uses: docker/build-push-action@v2 + timeout-minutes: 60 + with: + # TODO: use cache https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: 18-${{ steps.meta.outputs.labels }} + file: 18.Dockerfile + - name: Build and publish to Docker Hub uses: docker/build-push-action@v2 timeout-minutes: 60 @@ -53,4 +66,5 @@ jobs: platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + labels: 20-${{ steps.meta.outputs.labels }} + file: 20.Dockerfile diff --git a/Dockerfile b/18.Dockerfile similarity index 100% rename from Dockerfile rename to 18.Dockerfile diff --git a/20.Dockerfile b/20.Dockerfile new file mode 100644 index 0000000..bb71464 --- /dev/null +++ b/20.Dockerfile @@ -0,0 +1,44 @@ +FROM node:20-alpine + + +# * Same version as in Watchtower +ARG EXPRESS_VERSION=4.18.2 +ENV EXPRESS_VERSION $EXPRESS_VERSION + +# * path to the server files +ARG SERVER_PATH /opt/server +ENV SERVER_PATH=$SERVER_PATH + +# * Required to access to the globally installed modules +ENV NODE_PATH=/usr/local/lib/node_modules + +# * Add path to the stored pnpm packages +ENV PNPM_HOME=/root/.local/share/pnpm +ENV PATH=$PATH:$PNPM_HOME + +# * Directory where the Nhost project is located +ENV NHOST_PROJECT_PATH=/opt/project + +# * Default package manager +ENV PACKAGE_MANAGER=pnpm + +# * Use a custom Typescript compiler rather than the one from the project +ENV SWC_NODE_PROJECT $SERVER_PATH/tsconfig.json + +# install dependencies +RUN apk update && apk upgrade && \ + apk add --no-cache git openssh python3 make g++ + +# * Install packages that are required for this docker image to run +RUN npm install -g pnpm nodemon express@$EXPRESS_VERSION morgan glob@8.1.0 tsx @antfu/ni + +# * The pnpm store should be mounted in the same volume as node_modules (requires hard links) +# * See https://pnpm.io/6.x/npmrc#store-dir +RUN pnpm config set store-dir $NHOST_PROJECT_PATH/node_modules/.pnpm-store + +# * Copy server files +COPY nodemon.json start.sh server.ts tsconfig.json $SERVER_PATH/ + +# * Change working directory to the Nhost project directory +WORKDIR $NHOST_PROJECT_PATH +ENTRYPOINT $SERVER_PATH/start.sh