Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ko to build the container image #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 12 additions & 34 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ on:
pull_request:
branches: [ 'main' ]

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

jobs:
build-and-push-image:
runs-on: ubuntu-latest
Expand All @@ -21,39 +17,21 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea # v4.1.1
- uses: actions/setup-go@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
go-version: '>=1.19'
- uses: imjasonh/[email protected]

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 # v3.2.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Sign the Docker image
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b #v2.8.1
- name: Sign the published Docker image
if: github.event_name != 'pull_request'
- if: github.event_name != 'pull_request'
env:
COSIGN_EXPERIMENTAL: "true"
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}
COSIGN_EXPERIMENTAL: true
run: cosign sign $(ko build ./cmd/golink --bare)

- if: github.event_name == 'pull_request'
env:
KO_DOCKER_REPO: ko.local
run: ko build ./cmd/golink

18 changes: 0 additions & 18 deletions Dockerfile

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ Two pieces of data should be on persistent volumes:

In the docker image, both are stored in `/root`, so you can mount a persistent volume at /root:

docker run -v /persistant/data:/root ghcr.io/tailscale/golink:main
docker run -v /persistant/data:/root ghcr.io/tailscale/golink:main \
--sqlitedb /root/golink.db \
--verbose

No ports need to be exposed, whether running as a binary or in docker.
golink will listen on port 80 on the tailscale interface, so can be accessed at http://go/.
Expand Down