Skip to content

Commit

Permalink
Refactor build configuration and Dockerfile for Platypus web app admin
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed Oct 2, 2024
1 parent 595c243 commit 9789cb7
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: worker
name: platypus-admin

on:
push:
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_NAME: ${{ github.repository }}-admin

jobs:
docker:
Expand Down Expand Up @@ -53,7 +51,7 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
file: cmd/admin/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/docker-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: platypus-agent

on:
push:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-agent

jobs:
docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Selfhosted Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: cmd/agent/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
58 changes: 58 additions & 0 deletions .github/workflows/docker-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: platypus-frontend

on:
push:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-frontend

jobs:
docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Selfhosted Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: web/platypus
file: web/platypus/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
58 changes: 58 additions & 0 deletions .github/workflows/docker-server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: platypus-server

on:
push:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-server

jobs:
docker:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=sha,prefix=,suffix=,format=short
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Selfhosted Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: cmd/server/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
23 changes: 23 additions & 0 deletions cmd/admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22.6 AS builder

ARG TARGETOS
ARG TARGETARCH

RUN go install github.com/goreleaser/goreleaser/[email protected]

WORKDIR /app
COPY . .

# Check if the current commit is tagged, and build accordingly
RUN if git describe --tags --exact-match >/dev/null 2>&1; then \
echo "Commit is tagged. Creating a release build."; \
goreleaser build --id platypus-admin --clean; \
else \
echo "Commit is not tagged. Creating a snapshot build."; \
goreleaser build --id platypus-admin --clean --snapshot; \
fi

FROM alpine:3.12
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/dist/platypus-admin_${TARGETOS}_${TARGETARCH}_v1/platypus-admin /usr/local/bin/platypus-admin
ENTRYPOINT [ "/usr/local/bin/platypus-admin" ]
23 changes: 23 additions & 0 deletions cmd/agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22.6 AS builder

ARG TARGETOS
ARG TARGETARCH

RUN go install github.com/goreleaser/goreleaser/[email protected]

WORKDIR /app
COPY . .

# Check if the current commit is tagged, and build accordingly
RUN if git describe --tags --exact-match >/dev/null 2>&1; then \
echo "Commit is tagged. Creating a release build."; \
goreleaser build --id platypus-agent --clean; \
else \
echo "Commit is not tagged. Creating a snapshot build."; \
goreleaser build --id platypus-agent --clean --snapshot; \
fi

FROM alpine:3.12
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/dist/platypus-agent_${TARGETOS}_${TARGETARCH}_v1/platypus-agent /usr/local/bin/platypus-agent
ENTRYPOINT [ "/usr/local/bin/platypus-agent" ]
23 changes: 23 additions & 0 deletions cmd/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM golang:1.22.6 AS builder

ARG TARGETOS
ARG TARGETARCH

RUN go install github.com/goreleaser/goreleaser/[email protected]

WORKDIR /app
COPY . .

# Check if the current commit is tagged, and build accordingly
RUN if git describe --tags --exact-match >/dev/null 2>&1; then \
echo "Commit is tagged. Creating a release build."; \
goreleaser build --id platypus-server --clean; \
else \
echo "Commit is not tagged. Creating a snapshot build."; \
goreleaser build --id platypus-server --clean --snapshot; \
fi

FROM alpine:3.12
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/dist/platypus-server_${TARGETOS}_${TARGETARCH}_v1/platypus-server /usr/local/bin/platypus-server
ENTRYPOINT [ "/usr/local/bin/platypus-server" ]

0 comments on commit 9789cb7

Please sign in to comment.