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
69 changes: 69 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: publish-docker
on:
workflow_run:
workflows:
- build
types:
- completed
branches:
- main
- publish_docker
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
publish-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# - name: Extract api-metadata (tags, labels) for Docker
# id: api-meta
# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api
# - name: create .npmrc
# run: 'echo -e "//npm.pkg.github.com/:_authToken=$GITHUB_TOKEN\n@eresearchqut:registry=https://npm.pkg.github.com/" > .secret_npmrc'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
# build-args: |
# PROJECT=api
# PORT=3001
# secret-files: |
# "npmrc=./.secret_npmrc"
platforms: linux/amd64,linux/arm64
target: runner
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
24 changes: 19 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Minimal Dockerfile to run the NestJS proofpoint-mock API using pnpm
FROM node:20-alpine
# Dockerfile to run the NestJS proofpoint-mock API using pnpm

# Create app directory
WORKDIR /app
ARG NODE_VERSION=22.14.0
FROM node:${NODE_VERSION}-alpine AS alpine

# Setup pnpm on the alpine base
FROM alpine AS base

# Enable and prepare pnpm via Corepack (bundled with Node.js >=16.13)
RUN corepack enable && corepack prepare pnpm@9 --activate

# Build the project
FROM base AS builder

# Create app directory
WORKDIR /app

# Install dependencies with pnpm; leverage lockfile if present
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --prefer-offline --strict-peer-dependencies=false
Expand All @@ -15,10 +23,16 @@ RUN pnpm install --prefer-offline --strict-peer-dependencies=false
COPY tsconfig.json ./
COPY src ./src

# Nest runner
FROM base AS runner

WORKDIR /app
COPY --from=builder /app .

# Expose API port
ARG PORT=3000
ENV PORT=${PORT}
#ENV NODE_ENV=production
ENV NODE_ENV=production
EXPOSE ${PORT}

# Start the application (ts-node is in devDependencies)
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,31 @@ curl --location 'http://localhost:3000/send' \
}
]
}'
```
```

## Usage (docker compose)
1. Add the following to `docker-compose`:
1. Select a smtp service (e.g. mailhog) and configure it
2. Configure the proofpoint-mock service
```
smtp:
image: mailhog/mailhog:v1.0.1
container_name: smtp_server_dev
restart: unless-stopped
ports:
- "1025:1025" # SMTP
- "8025:8025" # Web UI

proofpoint:
container_name: proofpoint_dev
image: ghcr.io/eresearchqut/proofpoint-mock:publish_docker
environment:
- PORT=3000
- SMTP_HOST=smtp
- SMTP_PORT=1025
depends_on:
- smtp
ports:
- "7002:3000"
```
2. Check emails: http://localhost:8025