Skip to content

Commit

Permalink
feat: docker images (#18)
Browse files Browse the repository at this point in the history
* feat: docker images

* chore: add alpine packages, fix linker issues

* fix: exclude docker build from archive

* fix: use the correct container registry

* fix: github container registry login

* chore: add docker and goreleaser to README

* chore: add links to README
  • Loading branch information
Lustyn authored Jan 19, 2022
1 parent 4641ddf commit afa888b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ jobs:
go mod init casket
cd ..
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
30 changes: 29 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,39 @@ builds:
goarch: 386
- goos: darwin
goarch: arm
# Build specifically for the Docker image with CGO disabled for MUSL compatibility
- id: "docker"
main: main.go
dir: ./casket
binary: casket
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64

dockers:
- ids:
- docker
dockerfile: Dockerfile.release
image_templates:
- "ghcr.io/tmpim/casket:latest"
- "ghcr.io/tmpim/casket:{{ .Tag }}"
- "ghcr.io/tmpim/casket:v{{ .Major }}"
- "ghcr.io/tmpim/casket:v{{ .Major }}.{{ .Minor }}"

# Set dist directory to build/ since we have files in dist/
dist: build

before:
hooks:
- sh ./.prerelease.sh

archives:
- format_overrides:
- builds:
- casket
format_overrides:
- goos: windows
format: zip
checksum:
Expand All @@ -37,5 +63,7 @@ release:
github:
owner: tmpim
name: casket
ids:
- casket
draft: true
prerelease: auto
22 changes: 22 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine:3

COPY casket /usr/bin/

RUN apk --no-cache add tzdata ca-certificates && update-ca-certificates

# Create empty directories for:
# /config: where the casketfile other configuration files will be stored
# /data: where the persistent data will be stored (certificates, etc)
# /www: the default web root
# NOTE: it is your responsibility (the user) to create bind mounts or volumes.
RUN mkdir /config \
&& mkdir /data \
&& mkdir /www

# Set the casket path to store certificates in /data
ENV CASKETPATH=/data

# Set working directory to /config so that casket will load /config/Casketfile
WORKDIR /config

ENTRYPOINT ["casket", "-agree", "-root", "/www"]
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,38 @@ adding our own touches for convenience and usability.
## Building

To build the main casket executable, the following procedure can be used:
```
```sh
git clone https://github.com/tmpim/casket
cd casket
go build -o ./build/casket ./casket
# The executable can now be found at ./build/casket
```

Note these development builds will lack version information and will report a version of (devel)
Note these development builds will lack version information and will report a version of (devel). You can also instead create a snapshot build using the following procedure:

```sh
go install github.com/goreleaser/goreleaser@latest # Install goreleaser
goreleaser build --snapshot --rm-dist --single-target --id casket # Create a snapshot build
# The executable can now be found at ./build/casket_linux_amd64/casket
```

## Docker

A docker image is provided for the latest version of Casket from [`ghcr.io/tmpim/casket`](https://ghcr.io/tmpim/casket).

Example using [`docker-compose`](https://docs.docker.com/compose/):
```yaml
version: "3.8"

services:
casket:
image: ghcr.io/tmpim/casket:latest # or a specific version like v1.2
restart: unless-stopped
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
volumes:
- ./Casketfile:/config/Casketfile # Pass in your casket config
- ./static:/www # Pass in your static content
- casket_data:/data # Create a volume to store persistent data (e.g. certificates)
```

0 comments on commit afa888b

Please sign in to comment.