diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..9f0cd20 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,56 @@ +name: Publish Docker Image + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +permissions: + contents: read + +jobs: + docker: + runs-on: ubuntu-latest + env: + IMAGE_NAME: ${{ vars.DOCKERHUB_IMAGE }} + steps: + - name: Validate Docker Hub image name + run: | + if [ -z "${IMAGE_NAME}" ]; then + echo "Repository variable DOCKERHUB_IMAGE must be set, for example yusufipk/openframe" >&2 + exit 1 + fi + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=sha,prefix=sha- + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 629b8e3..846fbe8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM oven/bun:1 AS base +FROM docker.io/oven/bun:1 AS base WORKDIR /app FROM base AS deps @@ -23,7 +23,7 @@ ENV NODE_ENV=production RUN bun run db:generate RUN bun run build -FROM oven/bun:1 AS runner +FROM docker.io/oven/bun:1 AS runner WORKDIR /app ENV NODE_ENV=production ENV PORT=3000