ci: publish multi-arch images
This commit is contained in:
1 parent
ce0be8e0e3
commit
9eb6c6a8fa
3 files changed
+36
-7
No files matched your search
@@ -47,6 +47,9 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Log in
|
- name: Log in
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
@@ -70,7 +73,7 @@ jobs:
|
|||||||
context: .
|
context: .
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
push: true
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64,linux/arm64
|
||||||
build-args: |
|
build-args: |
|
||||||
VITE_SITE_URL=${{ vars.VITE_SITE_URL }}
|
VITE_SITE_URL=${{ vars.VITE_SITE_URL }}
|
||||||
VITE_API_BASE_URL=/api/v1
|
VITE_API_BASE_URL=/api/v1
|
||||||
|
|||||||
+7
-6
@@ -1,4 +1,4 @@
|
|||||||
FROM oven/bun:alpine AS web-build
|
FROM --platform=$BUILDPLATFORM oven/bun:alpine AS web-build
|
||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
|
|
||||||
@@ -14,26 +14,27 @@ COPY apps/web ./apps/web
|
|||||||
RUN bun install --frozen-lockfile
|
RUN bun install --frozen-lockfile
|
||||||
RUN bun run build:web
|
RUN bun run build:web
|
||||||
|
|
||||||
FROM golang:1.26-alpine AS api-build
|
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS api-build
|
||||||
|
|
||||||
WORKDIR /src/apps/api
|
WORKDIR /src/apps/api
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
COPY apps/api/go.mod apps/api/go.sum ./
|
COPY apps/api/go.mod apps/api/go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY apps/api ./
|
COPY apps/api ./
|
||||||
|
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/xdrop-api ./cmd/api
|
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build -o /out/xdrop-api ./cmd/api
|
||||||
|
|
||||||
FROM nginx:1.29-alpine
|
FROM nginx:1.29-alpine
|
||||||
|
|
||||||
COPY infra/xdrop/nginx.conf.template /etc/nginx/templates/default.conf.template
|
COPY infra/xdrop/nginx.conf.template /etc/nginx/templates/default.conf.template
|
||||||
COPY infra/xdrop/entrypoint.sh /usr/local/bin/xdrop-entrypoint
|
COPY --chmod=755 infra/xdrop/entrypoint.sh /usr/local/bin/xdrop-entrypoint
|
||||||
COPY --from=web-build /workspace/apps/web/dist /usr/share/nginx/html
|
COPY --from=web-build /workspace/apps/web/dist /usr/share/nginx/html
|
||||||
COPY --from=api-build /out/xdrop-api /usr/local/bin/xdrop-api
|
COPY --from=api-build /out/xdrop-api /usr/local/bin/xdrop-api
|
||||||
|
|
||||||
RUN chmod +x /usr/local/bin/xdrop-entrypoint
|
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/xdrop-entrypoint"]
|
ENTRYPOINT ["/usr/local/bin/xdrop-entrypoint"]
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { readFileSync } from 'node:fs'
|
||||||
|
import { join } from 'node:path'
|
||||||
|
|
||||||
|
import { describe, expect, it } from 'bun:test'
|
||||||
|
|
||||||
|
const repoRoot = join(import.meta.dir, '..')
|
||||||
|
|
||||||
|
describe('publish image configuration', () => {
|
||||||
|
it('publishes a multi-platform image for amd64 and arm64', () => {
|
||||||
|
const workflow = readFileSync(
|
||||||
|
join(repoRoot, '.github', 'workflows', 'publish-images.yml'),
|
||||||
|
'utf8',
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(workflow).toContain('platforms: linux/amd64,linux/arm64')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('builds the API binary for the target image architecture', () => {
|
||||||
|
const dockerfile = readFileSync(join(repoRoot, 'Dockerfile'), 'utf8')
|
||||||
|
|
||||||
|
expect(dockerfile).toContain('ARG TARGETOS')
|
||||||
|
expect(dockerfile).toContain('ARG TARGETARCH')
|
||||||
|
expect(dockerfile).toContain('GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH:-amd64} go build')
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in new issue
Block a user