Skip to content

Commit 0fb545d

Browse files
committed
Updates to use GoReleaser for Docker images
GitHub Action: * Deleted docker relase action in favour of using GoReleaser for Docker too * In the 'release binary' ... * Renamed to more generic 'release.yaml' as we do more than the binary now * Removed 'skip announce', as we haven't got anything configured, added skip flags for homebrew and docker * Added the steps required for Docker builds in GoReleaser GoReleaser config: * Updated to add docker config for multi-platform builds Dockerfile: * Drop version arg and push via pipeline in GoReleaser for label metadata * Allow more env vars to be used to configure log path, config and runtime fiile docker-compose: * Ditched .env file as it's required if you don't want an error * Ditched 'args' as unneeded, matched the env vars and defaults with Dockerfile for clarity
1 parent 8d4fe55 commit 0fb545d

File tree

5 files changed

+70
-102
lines changed

5 files changed

+70
-102
lines changed

.github/workflows/release-docker.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/release-binary.yaml renamed to .github/workflows/release.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Binary
1+
name: Release
22

33
on:
44
release:
@@ -9,8 +9,12 @@ on:
99
description: "Skip binary publish"
1010
required: false
1111
default: "false"
12-
skip_announce:
13-
description: "Skip announce"
12+
skip_docker:
13+
description: "Skip docker publish"
14+
required: false
15+
default: "false"
16+
skip_homebrew:
17+
description: "Skip homebrew publish"
1418
required: false
1519
default: "false"
1620

@@ -31,6 +35,19 @@ jobs:
3135
with:
3236
go-version-file: go.mod
3337

38+
# Setup QEMU, buildx and login to DockerHub, required for GoReleaser
39+
- name: Set up QEMU
40+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
44+
45+
- name: Login to DockerHub
46+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
47+
with:
48+
username: ${{ secrets.DOCKERHUB_USERNAME }}
49+
password: ${{ secrets.DOCKERHUB_TOKEN }}
50+
3451
- name: Run GoReleaser
3552
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
3653
with:
@@ -39,7 +56,8 @@ jobs:
3956
args: >
4057
release --clean
4158
${{ github.event.inputs.skip_publish == 'true' && ' --skip publish' || '' }}
42-
${{ github.event.inputs.skip_announce == 'true' && ' --skip announce' || '' }}
59+
${{ github.event.inputs.skip_docker == 'true' && ' --skip docker' || '' }}
60+
${{ github.event.inputs.skip_homebrew == 'true' && ' --skip homebrew' || '' }}
4361
env:
4462
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4563
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,36 @@ homebrew_casks:
6868
system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/mcpd"]
6969
end
7070
71+
dockers:
72+
- goarch: amd64
73+
use: buildx
74+
image_templates:
75+
- "mzdotai/mcpd:{{ .Tag }}-amd64"
76+
- "mzdotai/mcpd:latest-amd64"
77+
build_flag_templates:
78+
- "--pull"
79+
- "--platform=linux/amd64"
80+
- "--label=org.opencontainers.image.version={{ .Tag }}"
81+
- goarch: arm64
82+
use: buildx
83+
image_templates:
84+
- "mzdotai/mcpd:{{ .Tag }}-arm64"
85+
- "mzdotai/mcpd:latest-arm64"
86+
build_flag_templates:
87+
- "--pull"
88+
- "--platform=linux/arm64"
89+
- "--label=org.opencontainers.image.version={{ .Tag }}"
90+
91+
docker_manifests:
92+
- name_template: "mzdotai/mcpd::{{ .Tag }}"
93+
image_templates:
94+
- "mzdotai/mcpd:{{ .Tag }}-amd64"
95+
- "mzdotai/mcpd:{{ .Tag }}-arm64"
96+
- name_template: "mzdotai/mcpd:latest"
97+
image_templates:
98+
- "mzdotai/mcpd:latest-amd64"
99+
- "mzdotai/mcpd:latest-arm64"
100+
71101
changelog:
72102
disable: true
73103

Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ FROM ghcr.io/astral-sh/uv:0.7.20 AS uv-builder
1111
# ==============================================================================
1212
FROM node:current-alpine3.22
1313

14-
ARG MCPD_VERSION=unknown
15-
1614
# --- Metadata ---
17-
# The version label should be dynamically overridden in a CI/CD pipeline
18-
# (e.g., --label "org.opencontainers.image.version=${GIT_TAG}").
1915
LABEL org.opencontainers.image.authors="Mozilla AI <[email protected]>"
2016
LABEL org.opencontainers.image.description="A container for the mcpd application."
21-
LABEL org.opencontainers.image.version=$MCPD_VERSION
17+
# The version label should be dynamically overridden in a CI/CD pipeline
18+
LABEL org.opencontainers.image.version="dev"
2219

2320
ARG MCPD_USER=mcpd
2421
ARG MCPD_HOME=/home/$MCPD_USER
2522

2623
# Sensible defaults but can be easily overridden by the user with `docker run -e KEY=VALUE`.
2724
ENV MCPD_API_PORT=8090
2825
ENV MCPD_LOG_LEVEL=info
26+
ENV MCPD_LOG_PATH=/var/log/mcpd/mcpd.log
27+
ENV MCPD_CONFIG_FILE=/etc/mcpd/.mcpd.toml
28+
ENV MCPD_RUNTIME_FILE=/home/mcpd/.config/mcpd/secrets.prd.toml
2929

3030
# - Installs 'tini', a lightweight init system to properly manage processes.
3131
# - Adds a dedicated non-root group and user for security (using the ARG).
@@ -61,6 +61,13 @@ ENTRYPOINT ["/sbin/tini", "--"]
6161
CMD mcpd daemon \
6262
--addr 0.0.0.0:$MCPD_API_PORT \
6363
--log-level $MCPD_LOG_LEVEL \
64-
--log-path /var/log/mcpd/mcpd.log \
65-
--config-file /etc/mcpd/.mcpd.toml \
66-
--runtime-file /home/mcpd/.config/mcpd/secrets.prd.toml
64+
--log-path $MCPD_LOG_PATH \
65+
--config-file $MCPD_CONFIG_FILE \
66+
--runtime-file $MCPD_RUNTIME_FILE
67+
68+
# Example run:
69+
# docker run -p 8090:8090
70+
# -v $PWD/.mcpd.toml:/etc/mcpd/.mcpd.toml \
71+
# -v HOME/.config/mcpd/secrets.dev.toml:/home/mcpd/.config/mcpd/secrets.prd.toml \
72+
# -e MCPD_LOG_LEVEL=debug \
73+
# mzdotai/mcpd:v0.0.2

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ services:
22
mcpd:
33
build:
44
context: .
5-
args:
6-
MCPD_API_PORT: ${MCPD_API_PORT:-8090}
75
container_name: mcpd
8-
env_file: .env
96
environment:
107
MCPD_API_PORT: ${MCPD_API_PORT:-8090}
118
MCPD_LOG_LEVEL: ${MCPD_LOG_LEVEL:-INFO}
9+
MCPD_LOG_PATH: ${MCPD_LOG_PATH:-/var/log/mcpd/mcpd.log}
10+
MCPD_CONFIG_FILE: ${MCPD_CONFIG_FILE:-/etc/mcpd/.mcpd.toml}
11+
MCPD_RUNTIME_FILE: ${MCPD_RUNTIME_FILE:-/home/mcpd/.config/mcpd/secrets.prd.toml}
1212
ports:
1313
- "${MCPD_API_PORT:-8090}:${MCPD_API_PORT:-8090}"
1414
volumes:

0 commit comments

Comments
 (0)