Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ components.json
graphql.config.ts

# Development utilities
nitroping
# nitroping # SDK needed for build

# Include SDK for build
sdk
122 changes: 103 additions & 19 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ on:
- main
tags:
- 'v*'
pull_request:
branches:
- main

env:
REGISTRY: docker.io
IMAGE_NAME: productdevbook/nitroping

jobs:
build:
build-amd64:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -29,7 +26,6 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
Expand All @@ -41,27 +37,115 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,suffix=-amd64
type=semver,pattern={{version}},suffix=-amd64
type=semver,pattern={{major}}.{{minor}},suffix=-amd64
type=semver,pattern={{major}},suffix=-amd64
type=raw,value=latest-amd64,enable={{is_default_branch}}

- name: Build and push AMD64 Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: production
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=amd64
cache-to: type=gha,mode=max,scope=amd64
build-args: |
DATABASE_URL=postgresql://dummy:dummy@localhost:5432/dummy
JWT_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
ENCRYPTION_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
WEBHOOK_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
AUTO_MIGRATE=false

build-arm64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- 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.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,suffix=-arm64
type=semver,pattern={{version}},suffix=-arm64
type=semver,pattern={{major}}.{{minor}},suffix=-arm64
type=semver,pattern={{major}},suffix=-arm64
type=raw,value=latest-arm64,enable={{is_default_branch}}

- name: Build and push ARM64 Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: production
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=arm64
cache-to: type=gha,mode=max,scope=arm64
build-args: |
DATABASE_URL=postgresql://dummy:dummy@localhost:5432/dummy
JWT_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
ENCRYPTION_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
WEBHOOK_SECRET=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
AUTO_MIGRATE=false

create-manifest:
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
permissions:
contents: read
packages: write

steps:
- 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.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata for manifest
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Test Docker image
if: github.event_name == 'pull_request'
- name: Create and push manifest
run: |
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} --help || true
for tag in ${{ steps.meta.outputs.tags }}; do
docker buildx imagetools create \
--tag ${tag} \
${tag}-amd64 \
${tag}-arm64
done
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,21 @@ RUN pnpm install --frozen-lockfile

FROM base AS build

# Build arguments for environment variables needed during build
ARG DATABASE_URL
ARG JWT_SECRET
ARG ENCRYPTION_KEY
ARG WEBHOOK_SECRET
ARG AUTO_MIGRATE

# Set environment variables for build
ENV NODE_OPTIONS="--max-old-space-size=4096"
ENV DATABASE_URL=$DATABASE_URL
ENV JWT_SECRET=$JWT_SECRET
ENV ENCRYPTION_KEY=$ENCRYPTION_KEY
ENV WEBHOOK_SECRET=$WEBHOOK_SECRET
ENV AUTO_MIGRATE=$AUTO_MIGRATE

RUN pnpm run build

FROM base AS dev
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"jsonwebtoken": "^9.0.2",
"lucide-vue-next": "^0.539.0",
"nitro-graphql": "^1.1.3",
"nitroping": "link:./sdk",
"nitroping": "^0.1.0",
"nuxt": "^4.0.3",
"pinia": "^3.0.3",
"postgres": "^3.4.7",
Expand Down
10 changes: 8 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.