Skip to content

Commit

Permalink
Merge pull request #1 from strangelove-ventures/andrew/gh_action_dock…
Browse files Browse the repository at this point in the history
…er_publish

Add github action for docker build and push
  • Loading branch information
agouin authored Aug 28, 2022
2 parents 8e8aef9 + dc85d81 commit fba872e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and push a Docker image

on:
push:
tags:
- '**'
branches:
- '**'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
FROM boxboat/config-merge:latest as config-merge
USER root
RUN apk add wget curl lz4 nano jq
RUN wget -O /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/download/v1.26.0/dasel_linux_amd64
RUN if [ "$(uname -m)" = "aarch64" ]; then \
ARCH=arm64; \
else \
ARCH=amd64; \
fi; \
wget -O /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/download/v1.26.0/dasel_linux_$ARCH
RUN chmod +x /usr/local/bin/dasel
WORKDIR /root
WORKDIR /root

0 comments on commit fba872e

Please sign in to comment.