diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/.gitea/workflows/build-and-publish.yml b/.gitea/workflows/build-and-publish.yml new file mode 100644 index 0000000..8ec4cbe --- /dev/null +++ b/.gitea/workflows/build-and-publish.yml @@ -0,0 +1,61 @@ +name: Build and Publish + +on: + push: + branches: [main] + tags: ["v*"] + +env: + REGISTRY: git.atlashorizon.net + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # ACTION_TOKEN is a personal access token with package read/write scope, + # stored as a runner secret (the automatic GITEA_TOKEN doesn't work for + # registry auth on this instance). + - name: Log in to Gitea container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.ACTION_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}} + type=sha + labels: | + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # Links the container package to this repository so it shows up on the + # repo's Packages tab. Returns an error if it's already linked, which is + # fine — hence the fallback message instead of failing the job. + - name: Link package to repository + run: | + curl -sf -X POST \ + -H "Authorization: token ${{ secrets.ACTION_TOKEN }}" \ + "${{ github.server_url }}/api/v1/packages/${{ github.repository_owner }}/container/${{ github.event.repository.name }}/-/link/${{ github.event.repository.name }}" \ + && echo "Package linked to repository" \ + || echo "Link skipped (already linked, or token lacks permission)" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..81fae70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:22-alpine AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY . . +RUN npm run build + +# Runtime stage: serve the built app with Express +FROM node:22-alpine +WORKDIR /app +ENV NODE_ENV=production +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev +COPY server.js ./ +COPY --from=build /app/dist ./dist +EXPOSE 3000 +USER node +CMD ["node", "server.js"] \ No newline at end of file