commit 9960bc21497a2e6ad8c93f4c9a901d0f1e8e7ab7 Author: stxer <166108056+stxer@users.noreply.github.com> Date: Fri Sep 6 04:54:10 2024 -0500 init repo diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml new file mode 100644 index 0000000..7515891 --- /dev/null +++ b/.github/workflows/build-image.yml @@ -0,0 +1,45 @@ +name: Create and publish Docker image + +on: + workflow_dispatch: + inputs: + rev: + description: 'branch or tag or commit to build' + required: true + default: 'main' + tag-name: + description: 'image tag name' + required: true + default: 'latest' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + TAG_NAME: ${{ github.event.inputs.tag-name }} + REV: ${{ github.event.inputs.rev }} + PRE_BUILD_SCRIPT: ${{ secrets.PRE_BUILD_SCRIPT }} + +jobs: + build: + name: Build ${{ github.event.inputs.tag-name }} with ${{ github.event.inputs.rev }} + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + run: | + bash -c "$PRE_BUILD_SCRIPT" + export IMAGE_TAG="$REGISTRY/$IMAGE_NAME:$TAG_NAME" + echo "Building image $IMAGE_TAG" + docker build -t $IMAGE_TAG . + docker push $IMAGE_TAG diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7dc85f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build +/source diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..42c2a78 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM node:18-alpine AS build + +WORKDIR /app + +COPY ./source . + +RUN npm install -g pnpm@8.9.1 +RUN pnpm i +RUN pnpm build + +FROM node:18-alpine + +WORKDIR /app + +COPY --from=build /app/next.config.js /app/next.config.js +COPY --from=build /app/public /app/public +COPY --from=build /app/.next/static /app/.next/static +COPY --from=build /app/.next/standalone /app + +CMD [ "node", "server.js" ]