Skip to content

Commit

Permalink
Refactor docker images (#1355)
Browse files Browse the repository at this point in the history
* Refactor docker images and update go version to 1.18.6
  • Loading branch information
johscheuer authored Sep 21, 2022
1 parent 2bd11bf commit eba161d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 124 deletions.
66 changes: 11 additions & 55 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18.5
go-version: 1.18.6
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18.5
go-version: 1.18.6
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18.5
go-version: 1.18.6
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -134,7 +134,6 @@ jobs:
run: |
make test
build_images:
if: github.ref != 'refs/heads/main'
name: Build Docker images
runs-on: ubuntu-latest
strategy:
Expand All @@ -149,77 +148,34 @@ jobs:
name: foundationdb/fdb-kubernetes-operator
tagSuffix: ""
file: ./Dockerfile
baseImage: "docker.io/debian:bullseye"
- image: fdb-kubernetes-operator-distroless
context: ./
name: foundationdb/fdb-kubernetes-operator
tagSuffix: -distrolesss
file: ./distrolesss.dockerfile
- image: fdb-data-loader
context: ./sample-apps/data-loader
name: foundationdb/fdb-data-loader
tagSuffix: ""
file: ./sample-apps/data-loader/Dockerfile
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get the sha
id: get_sha
run: echo ::set-output name=TAG::${GITHUB_SHA}
- name: Build image
uses: docker/build-push-action@v2
with:
build-args: TAG=${{ steps.get_sha.outputs.TAG }}
push: false
context: ${{ matrix.context }}
tags: ${{ matrix.name }}:latest${{ matrix.tagSuffix }}
file: ${{ matrix.file }}
push_images:
if: github.ref == 'refs/heads/main'
needs: build
name: Push Docker images
runs-on: ubuntu-latest
strategy:
matrix:
image:
- fdb-kubernetes-operator
- fdb-data-loader
- fdb-kubernetes-operator-distroless
include:
- image: fdb-kubernetes-operator
context: ./
name: foundationdb/fdb-kubernetes-operator
tagSuffix: ""
file: ./Dockerfile
- image: fdb-kubernetes-operator-distroless
context: ./
name: foundationdb/fdb-kubernetes-operator
tagSuffix: -distrolesss
file: ./distrolesss.dockerfile
baseImage: "gcr.io/distroless/base"
- image: fdb-data-loader
context: ./sample-apps/data-loader
name: foundationdb/fdb-data-loader
tagSuffix: ""
file: ./sample-apps/data-loader/Dockerfile
baseImage: ""
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get the sha
id: get_sha
run: echo ::set-output name=TAG::${GITHUB_SHA}
- name: Build and push to registry
- name: Build image
uses: docker/build-push-action@v2
with:
build-args: TAG=${{ steps.get_sha.outputs.TAG }}
push: true
build-args: |
TAG=${{ steps.get_sha.outputs.TAG }}
BASE_IMAGE=${{ matrix.baseImage }}
push: ${{ github.ref == 'refs/heads/main' }}
context: ${{ matrix.context }}
tags: ${{ matrix.name }}:latest${{ matrix.tagSuffix }}
file: ${{ matrix.file }}
11 changes: 8 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18.5
go-version: 1.18.6
# https://github.com/goreleaser/goreleaser/issues/1311
- name: Get current semver tag
run: echo "::set-output name=CURRENT_TAG::$(git describe --tags --match "v*" --abbrev=0)"
Expand All @@ -69,16 +69,19 @@ jobs:
name: foundationdb/fdb-kubernetes-operator
tagSuffix: ""
file: ./Dockerfile
baseImage: "docker.io/debian:bullseye"
- image: fdb-kubernetes-operator-distroless
context: ./
name: foundationdb/fdb-kubernetes-operator
tagSuffix: -distrolesss
file: ./distrolesss.dockerfile
file: ./Dockerfile
baseImage: "gcr.io/distroless/base"
- image: fdb-data-loader
context: ./sample-apps/data-loader
name: foundationdb/fdb-data-loader
tagSuffix: ""
file: ./sample-apps/data-loader/Dockerfile
baseImage: ""
steps:
- name: Check out the repo
uses: actions/checkout@v2
Expand All @@ -95,7 +98,9 @@ jobs:
- name: Build and push to registry
uses: docker/build-push-action@v2
with:
build-args: TAG=${{ steps.get_tag.outputs.TAG }}
build-args: |
TAG=${{ steps.get_sha.outputs.TAG }}
BASE_IMAGE=${{ matrix.baseImage }}
push: true
context: ${{ matrix.context }}
tags: ${{ matrix.name }}:${{ steps.get_tag.outputs.TAG }}${{ matrix.tagSuffix }}
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ARG BASE_IMAGE=docker.io/debian:bullseye

# Build the manager binary
FROM docker.io/library/golang:1.18.5 as builder
FROM docker.io/library/golang:1.18.6 as builder

# Install FDB this version is only required to compile the fdb operator
ARG FDB_VERSION=6.2.29
Expand Down Expand Up @@ -40,7 +42,7 @@ RUN groupadd --gid 4059 fdb && \
mkdir -p /var/log/fdb && \
touch /var/log/fdb/.keep

FROM docker.io/debian:bullseye
FROM $BASE_IMAGE

VOLUME /usr/lib/fdb

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ If you already have Docker installed you can use the following steps to build an

```bash
# Create a container with amd64 which contains go
docker run --rm --entrypoint=/bin/bash -ti --platform="linux/amd64" -v $(pwd):/work -w /work docker.io/library/golang:1.18.5 ./scripts/setup_container.sh
docker run --rm --entrypoint=/bin/bash -ti --platform="linux/amd64" -v $(pwd):/work -w /work docker.io/library/golang:1.18 ./scripts/setup_container.sh
# Now we can run the lint and test steps
make fmt lint test
```
Expand Down
63 changes: 0 additions & 63 deletions distrolesss.dockerfile

This file was deleted.

0 comments on commit eba161d

Please sign in to comment.