Skip to content

Commit

Permalink
Merge pull request #18 from flatcar-linux/jepio/publish-docker-container
Browse files Browse the repository at this point in the history
Update dockerfile and add github action to publish docker images.
  • Loading branch information
jepio authored Mar 8, 2022
2 parents d00c766 + ff2c550 commit 3d9d636
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build docker image
on:
push:
tags:
- v*
env:
REGISTRY: ghcr.io
IMAGE_NAME: flatcar-linux/ct

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:

- name: Get tag name
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Checkout repository
uses: actions/checkout@v2

- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ COPY . .
RUN apk update && apk add --virtual .build-deps bash git make \
&& make \
&& mv bin/ct /usr/bin/ \
&& mv Dockerfile.build-alpine /tmp \
&& rm -rf $GOPATH \
&& apk del .build-deps && rm -rf /var/cache/apk
WORKDIR /tmp
ENTRYPOINT ["/usr/bin/ct"]

FROM scratch
COPY --from=0 /usr/bin/ct /ct
ENTRYPOINT ["/ct"]
3 changes: 0 additions & 3 deletions Dockerfile.build-alpine

This file was deleted.

6 changes: 2 additions & 4 deletions docker-build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

set -e
VERSION=$(git describe)
docker build -t $VERSION .
docker run --rm --entrypoint tar $VERSION -c /usr/bin/ct Dockerfile.build-alpine \
| docker build -f Dockerfile.build-alpine --tag quay.io/coreos/ct:$VERSION -
docker tag quay.io/coreos/ct:$VERSION quay.io/coreos/ct:latest-dev
docker build --tag ghcr.io/flatcar-linux/ct:$VERSION .
docker tag ghcr.io/flatcar-linux/ct:$VERSION ghcr.io/flatcar-linux/ct:latest-dev
5 changes: 2 additions & 3 deletions docker-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

set -e
VERSION=$(git describe)
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" quay.io
docker push quay.io/coreos/ct:$VERSION
docker push quay.io/coreos/ct:latest-dev
docker push ghcr.io/flatcar-linux/ct:$VERSION
docker push ghcr.io/flatcar-linux/ct:latest-dev

0 comments on commit 3d9d636

Please sign in to comment.