Skip to content

Commit 4abf5a5

Browse files
Dockerize whatever-origin (#37)
* Init add github action * Remove reading .git directory * Add compose yml * Update compose.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 76c5ecb commit 4abf5a5

File tree

3 files changed

+77
-9
lines changed

3 files changed

+77
-9
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
tags: ["v*.*.*"]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Install cosign
27+
if: github.event_name != 'pull_request'
28+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
29+
with:
30+
cosign-release: "v2.2.4"
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
34+
35+
- name: Log into registry ${{ env.REGISTRY }}
36+
if: github.event_name != 'pull_request'
37+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract Docker metadata
44+
id: meta
45+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
tags: |
49+
type=raw,value=latest
50+
type=semver,pattern={{version}}
51+
type=semver,pattern={{major}}.{{minor}}
52+
type=sha,prefix=sha-,format=short
53+
54+
- name: Build and push Docker image
55+
id: build-and-push
56+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
57+
with:
58+
context: .
59+
push: ${{ github.event_name != 'pull_request' }}
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
platforms: linux/amd64,linux/arm64
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
66+
- name: Sign the published Docker image
67+
if: ${{ github.event_name != 'pull_request' }}
68+
env:
69+
TAGS: ${{ steps.meta.outputs.tags }}
70+
DIGEST: ${{ steps.build-and-push.outputs.digest }}
71+
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
whatever-origin:
3+
image: ghcr.io/reynaldichernando/whatever-origin:latest
4+
ports:
5+
- 80:8080
6+
restart: always

main.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io/ioutil"
77
"net/http"
88
"os"
9-
"strings"
109
"sync"
1110
"time"
1211

@@ -54,14 +53,6 @@ func init() {
5453
if err != nil {
5554
panic(err)
5655
}
57-
58-
commit, err := ioutil.ReadFile(".git/refs/heads/master")
59-
60-
if err != nil {
61-
panic(err)
62-
}
63-
64-
getLogger.AddField("git", strings.TrimSpace(string(commit)))
6556
}
6657

6758
func CORS(next http.Handler) http.Handler {

0 commit comments

Comments
 (0)