Skip to content

Commit

Permalink
Change build process to use busybox
Browse files Browse the repository at this point in the history
  • Loading branch information
gcleroux committed Jul 30, 2024
1 parent 0c31151 commit 898dd5b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,19 @@ jobs:
contents: read
packages: write

strategy:
matrix:
go-version: [1.22.x]

outputs:
tags: ${{ steps.meta.outputs.tags }}

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Print branch name
id: extract_branch
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=release_train;]$(echo ${GITHUB_REF#refs/heads/release/})"
- name: Build
run: go build -v -ldflags "-X main.version=${{ github.event.ref }} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%MZ)" -o ./substreams-sink-sql ./cmd/substreams-sink-sql

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
Expand All @@ -68,6 +56,10 @@ jobs:
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
build-args: |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
20 changes: 17 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
FROM gcr.io/distroless/base-debian12:latest
FROM golang:1.22.5-alpine3.20 AS build

ADD /substreams-sink-sql /app/substreams-sink-sql
ARG BUILDTIME
ARG VERSION
ARG REVISION

ENV PATH "$PATH:/app"
WORKDIR /build

COPY . .

RUN CGO_ENABLED=0 go build -v -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o ./substreams-sink-sql ./cmd/substreams-sink-sql

FROM gcr.io/distroless/static-debian12:latest

WORKDIR /app

COPY --from=busybox:1.36.1-uclibc /bin/sh /bin/sh
COPY --from=busybox:1.36.1-uclibc /bin/touch /bin/touch
COPY --from=build /build/substreams-sink-sql .

ENTRYPOINT ["/app/substreams-sink-sql"]

0 comments on commit 898dd5b

Please sign in to comment.