Skip to content

Commit 86b56a9

Browse files
committed
feat: template docker
1 parent 98f8cd9 commit 86b56a9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

.github/workflows/build.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Docker Publish
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
# Publish semver tags as releases.
7+
tags: ["v*.*.*"]
8+
9+
env:
10+
# Use docker.io for Docker Hub if empty
11+
REGISTRY: ghcr.io
12+
# github.repository as <account>/<repo>
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
26+
# Install the cosign tool except on PR
27+
28+
# Set up BuildKit Docker container builder to be able to build
29+
# multi-platform images and export cache
30+
# https://github.com/docker/setup-buildx-action
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3 # v3.0.0
33+
34+
# Login against a Docker registry except on PR
35+
# https://github.com/docker/login-action
36+
- name: Log into registry ${{ env.REGISTRY }}
37+
if: github.event_name != 'pull_request'
38+
uses: docker/login-action@v3 # v3.0.0
39+
with:
40+
registry: ${{ env.REGISTRY }}
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
# Extract metadata (tags, labels) for Docker
45+
# https://github.com/docker/metadata-action
46+
- name: Extract Docker metadata
47+
id: meta
48+
uses: docker/metadata-action@v5 # v5.0.0
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
52+
# Build and push Docker image with Buildx (don't push on PR)
53+
# https://github.com/docker/build-push-action
54+
- name: Build and push Docker image
55+
id: build-and-push
56+
uses: docker/build-push-action@v5 # v5.0.0
57+
with:
58+
context: .
59+
platforms: linux/amd64,linux/arm64
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu
2+
3+
# Install ping tool
4+
RUN apt-get update && apt-get install -y iputils-ping
5+
6+
# Keep container running
7+
ENTRYPOINT ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)