Skip to content

Commit

Permalink
Added: workflows to publish our own images
Browse files Browse the repository at this point in the history
  • Loading branch information
GoliathLabs committed Aug 8, 2022
1 parent 9d02e1f commit 61240da
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/buildkitd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[worker.oci]
max-parallelism = 4
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Docs: <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/customizing-dependency-updates>

version: 2

updates:
- package-ecosystem: python
directory: /
schedule: {interval: monthly}
reviewers: [freifunkMUC/salt-stack]
assignees: [freifunkMUC/salt-stack]

- package-ecosystem: github-actions
directory: /
schedule: {interval: monthly}
reviewers: [freifunkMUC/salt-stack]
assignees: [freifunkMUC/salt-stack]

- package-ecosystem: docker
directory: /
schedule: {interval: monthly}
reviewers: [freifunkMUC/salt-stack]
assignees: [freifunkMUC/salt-stack]
48 changes: 48 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build Docker image

on:
push:
branches:
- master
pull_request:

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

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
config: .github/buildkitd.toml
- name: Retrieve author data
run: |
echo AUTHOR=$(curl -sSL ${{ github.event.repository.owner.url }} | jq -r '.name') >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.authors=${{ env.AUTHOR }}
- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Inspect Docker image
run: docker image inspect ${{ steps.meta.outputs.tags }}
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Docker image
on:
push:
branches:
- master
tags:
- 'v*.*.*'

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

jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config: .github/buildkitd.toml
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Retrieve author data
run: |
echo AUTHOR=$(curl -sSL ${{ github.event.repository.owner.url }} | jq -r '.name') >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.authors=${{ env.AUTHOR }}
- name: Build container image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/ppc64le,linux/s390x
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM l.gcr.io/google/bazel:latest AS builder
FROM gcr.io/cloud-marketplace-containers/google/bazel:2.5.0 AS builder

WORKDIR /wgkex

Expand All @@ -8,7 +8,7 @@ RUN ["bazel", "build", "//wgkex/broker:app"]
RUN ["bazel", "build", "//wgkex/worker:app"]
RUN ["cp", "-rL", "bazel-bin", "bazel"]

FROM python:3
FROM python:3.10.6-bullseye
WORKDIR /wgkex

COPY --from=builder /wgkex/bazel /wgkex/
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ services:
- "9001:9001"

broker:
build: .
image: wgkex
image: ghcr.io/freifunkmuc/wgkex:latest
command: broker
restart: unless-stopped
ports:
Expand All @@ -32,8 +31,7 @@ services:
MQTT_TLS: ${MQTT_TLS-False}

worker:
build: .
image: wgkex
image: ghcr.io/freifunkmuc/wgkex:latest
command: worker
restart: unless-stopped
#volumes:
Expand Down

0 comments on commit 61240da

Please sign in to comment.