Skip to content

Commit

Permalink
Simplify microservice builds
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Apr 26, 2024
1 parent 04aad43 commit c7261d5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ jobs:
- name: Setup docker build
shell: bash
run: |-
# aka base build
if [ ${{ inputs.dockerFile }} == "Dockerfile" ]; then
echo "image=scyllaridae" >> $GITHUB_OUTPUT
exit 0
fi
# put the YML file in place so it's copied into the Docker container
DIR=$(dirname "${{ inputs.dockerFile }}")
cp ./$DIR/scyllaridae.yml .
Expand Down Expand Up @@ -61,6 +67,7 @@ jobs:
with:
context: .
file: ${{ inputs.dockerFile }}
build-args: TAG=${{steps.extract_branch.outputs.branch}}
push: true
tags: |
us-docker.pkg.dev/${{ secrets.GCLOUD_PROJECT }}/public/${{steps.setup.outputs.image}}:${{steps.extract_branch.outputs.branch}}-${{steps.extract_tag.outputs.tag}}
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@ jobs:
- name: Test with the Go CLI
run: go test -v ./...

find-images:
build-push-base:
needs: [lint-test]
uses: ./.github/workflows/build-push.yml
with:
dockerFile: Dockerfile
permissions:
contents: read
id-token: write
secrets: inherit

find-images:
needs: [build-push-base]
name: Find docker images needing built
runs-on: ubuntu-latest
outputs:
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.21-alpine

WORKDIR /app

RUN apk update && \
apk add openssl && \
openssl s_client -connect helloworld.letsencrypt.org:443 -showcerts </dev/null 2>/dev/null | sed -e '/-----BEGIN/,/-----END/!d' | tee "/usr/local/share/ca-certificates/ca.crt" >/dev/null && \
update-ca-certificates

COPY . ./
RUN go mod download && \
go build -o /app/scyllaridae && \
go clean -cache -modcache

ENTRYPOINT ["/app/scyllaridae"]
16 changes: 4 additions & 12 deletions docker-images/curl/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
FROM golang:1.21-alpine

WORKDIR /app
ARG TAG=main
FROM us-docker.pkg.dev/lehigh-lts-images/public/scyllaridae:${TAG}

RUN apk update && \
apk add openssl curl && \
openssl s_client -connect helloworld.letsencrypt.org:443 -showcerts </dev/null 2>/dev/null | sed -e '/-----BEGIN/,/-----END/!d' | tee "/usr/local/share/ca-certificates/ca.crt" >/dev/null && \
update-ca-certificates

COPY . ./
RUN go mod download && \
go build -o /app/scyllaridae && \
go clean -cache -modcache
apk add openssl curl

ENTRYPOINT ["/app/scyllaridae"]
COPY scyllaridae.yml /app/scyllaridae.yml

0 comments on commit c7261d5

Please sign in to comment.