Skip to content

Commit 63fadab

Browse files
Docker build for audius/api:{sha} (#93)
1 parent 45a31d2 commit 63fadab

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Login to DockerHub
18+
uses: docker/login-action@v3
19+
with:
20+
username: ${{ secrets.DOCKERHUB_USERNAME }}
21+
password: ${{ secrets.DOCKERHUB_TOKEN }}
22+
23+
- name: Extract metadata for Docker
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: audius/api
28+
tags: |
29+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
30+
type=sha,prefix=
31+
32+
- name: Build and push
33+
uses: docker/build-push-action@v5
34+
with:
35+
context: .
36+
push: true
37+
tags: ${{ steps.meta.outputs.tags }}
38+
labels: ${{ steps.meta.outputs.labels }}
39+
cache-from: type=registry,ref=audius/api:buildcache
40+
cache-to: type=registry,ref=audius/api:buildcache,mode=max

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.24-alpine AS builder
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bridge-amd64 main.go
12+
13+
FROM alpine:latest
14+
15+
WORKDIR /app
16+
17+
COPY --from=builder /app/bridge-amd64 /bin/bridge
18+
19+
EXPOSE 1323
20+
21+
CMD ["bridge"]

0 commit comments

Comments
 (0)