Skip to content

Commit bf72cb6

Browse files
author
Frederico Marques
committed
Initial commit
0 parents  commit bf72cb6

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
# Publish `master` as Docker `latest` image.
6+
branches:
7+
- master
8+
9+
# Publish `v1.2.3` tags as releases.
10+
tags:
11+
- v*
12+
13+
# Run tests for any PRs.
14+
pull_request:
15+
16+
env:
17+
# TODO: Change variable to your image's name.
18+
IMAGE_NAME: image
19+
20+
jobs:
21+
# Run tests.
22+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
23+
test:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Run tests
30+
run: |
31+
if [ -f docker-compose.test.yml ]; then
32+
docker-compose --file docker-compose.test.yml build
33+
docker-compose --file docker-compose.test.yml run sut
34+
else
35+
docker build . --file Dockerfile
36+
fi
37+
38+
# Push image to GitHub Packages.
39+
# See also https://docs.docker.com/docker-hub/builds/
40+
push:
41+
# Ensure test job passes before pushing image.
42+
needs: test
43+
44+
runs-on: ubuntu-latest
45+
if: github.event_name == 'push'
46+
47+
steps:
48+
- uses: actions/checkout@v2
49+
50+
- name: Build image
51+
run: docker build . --file Dockerfile --tag $IMAGE_NAME
52+
53+
- name: Log into registry
54+
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
55+
56+
- name: Push image
57+
run: |
58+
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
59+
60+
# Change all uppercase to lowercase
61+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
62+
63+
# Strip git ref prefix from version
64+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
65+
66+
# Strip "v" prefix from tag name
67+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
68+
69+
# Use Docker `latest` tag convention
70+
[ "$VERSION" == "master" ] && VERSION=latest
71+
72+
echo IMAGE_ID=$IMAGE_ID
73+
echo VERSION=$VERSION
74+
75+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
76+
docker push $IMAGE_ID:$VERSION

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM caddy:2.3.0-builder AS builder
2+
3+
# Metadata
4+
LABEL org.label-schema.vcs-url="https://github.com/wegift/caddy" \
5+
org.label-schema.docker.dockerfile="/Dockerfile"
6+
7+
RUN xcaddy build \
8+
--with github.com/silinternational/certmagic-storage-dynamodb@2.0.1
9+
10+
FROM caddy:2.3.0
11+
12+
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
default: docker_build
2+
3+
DOCKER_IMAGE ?= wegift/caddy
4+
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
5+
6+
ifeq ($(GIT_BRANCH), main)
7+
DOCKER_TAG = latest
8+
else
9+
DOCKER_TAG = $(GIT_BRANCH)
10+
endif
11+
12+
docker_build:
13+
@docker build \
14+
--build-arg VCS_REF=`git rev-parse --short HEAD` \
15+
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
16+
-t $(DOCKER_IMAGE):$(DOCKER_TAG) .

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Caddy Docker
2+
3+
Docker Image for Caddy https://github.com/caddyserver/caddy
4+
5+
Includes DynamoDB Storage adapter for CertMagic https://github.com/silinternational/certmagic-storage-dynamodb

0 commit comments

Comments
 (0)