+37
-37
.air.toml
+37
-37
.air.toml
···
3
tmp_dir = "tmp"
4
5
[build]
6
-
args_bin = []
7
-
bin = "./tmp/main"
8
-
cmd = "go build -o ./tmp/main ."
9
-
delay = 1000
10
-
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
11
-
exclude_file = []
12
-
exclude_regex = ["_test.go"]
13
-
exclude_unchanged = false
14
-
follow_symlink = false
15
-
full_bin = ""
16
-
include_dir = []
17
-
include_ext = ["go", "tpl", "tmpl", "html"]
18
-
include_file = []
19
-
kill_delay = "0s"
20
-
log = "build-errors.log"
21
-
poll = false
22
-
poll_interval = 0
23
-
post_cmd = []
24
-
pre_cmd = []
25
-
rerun = false
26
-
rerun_delay = 500
27
-
send_interrupt = false
28
-
stop_on_error = false
29
30
[color]
31
-
app = ""
32
-
build = "yellow"
33
-
main = "magenta"
34
-
runner = "green"
35
-
watcher = "cyan"
36
37
[log]
38
-
main_only = false
39
-
silent = false
40
-
time = false
41
42
[misc]
43
-
clean_on_exit = false
44
45
[proxy]
46
-
app_port = 0
47
-
enabled = false
48
-
proxy_port = 0
49
50
[screen]
51
-
clear_on_rebuild = false
52
-
keep_scroll = true
···
3
tmp_dir = "tmp"
4
5
[build]
6
+
args_bin = []
7
+
bin = "./tmp/main"
8
+
cmd = "go build -o ./tmp/main ./cmd/main.go"
9
+
delay = 1000
10
+
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
11
+
exclude_file = []
12
+
exclude_regex = ["_test.go"]
13
+
exclude_unchanged = false
14
+
follow_symlink = false
15
+
full_bin = ""
16
+
include_dir = []
17
+
include_ext = ["go", "tpl", "tmpl", "html"]
18
+
include_file = []
19
+
kill_delay = "0s"
20
+
log = "build-errors.log"
21
+
poll = false
22
+
poll_interval = 0
23
+
post_cmd = []
24
+
pre_cmd = []
25
+
rerun = false
26
+
rerun_delay = 500
27
+
send_interrupt = false
28
+
stop_on_error = false
29
30
[color]
31
+
app = ""
32
+
build = "yellow"
33
+
main = "magenta"
34
+
runner = "green"
35
+
watcher = "cyan"
36
37
[log]
38
+
main_only = false
39
+
silent = false
40
+
time = false
41
42
[misc]
43
+
clean_on_exit = false
44
45
[proxy]
46
+
app_port = 0
47
+
enabled = false
48
+
proxy_port = 0
49
50
[screen]
51
+
clear_on_rebuild = false
52
+
keep_scroll = true
+34
.github/workflows/build.yaml
+34
.github/workflows/build.yaml
···
···
1
+
name: Build
2
+
3
+
on:
4
+
push:
5
+
branches:
6
+
- main
7
+
release:
8
+
types:
9
+
- published
10
+
11
+
jobs:
12
+
build-and-deploy:
13
+
runs-on: ubuntu-latest
14
+
15
+
steps:
16
+
- name: Checkout Repository
17
+
uses: actions/checkout@v2
18
+
19
+
- name: Set up Docker Buildx
20
+
uses: docker/setup-buildx-action@v3
21
+
22
+
- name: Login to GitHub Container Registry
23
+
uses: docker/login-action@v1
24
+
with:
25
+
registry: ghcr.io
26
+
username: ${{ github.actor }}
27
+
password: ${{ secrets.GITHUB_TOKEN }}
28
+
29
+
- name: Docker Buildx
30
+
run: |
31
+
docker buildx build \
32
+
--platform linux/amd64,linux/arm64 \
33
+
--tag ghcr.io/${{ github.repository_owner }}/piper:${GITHUB_REF_NAME#refs/tags/v} \
34
+
--push .
+24
Dockerfile
+24
Dockerfile
···
···
1
+
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:latest as builder
2
+
3
+
ARG TARGETPLATFORM
4
+
ARG BUILDPLATFORM
5
+
ARG TARGETOS
6
+
ARG TARGETARCH
7
+
8
+
# step 1. dep cache
9
+
WORKDIR /app
10
+
ARG TARGETPLATFORM=${BUILDPLATFORM:-linux/amd64}
11
+
COPY go.mod go.sum ./
12
+
RUN go mod download
13
+
14
+
# step 2. build the actual app
15
+
WORKDIR /app
16
+
COPY . .
17
+
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o main ./cmd/main.go
18
+
ARG TARGETOS=${TARGETPLATFORM%%/*}
19
+
ARG TARGETARCH=${TARGETPLATFORM##*/}
20
+
21
+
FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
22
+
WORKDIR /app/
23
+
COPY --from=builder /app/main /app/main
24
+
ENTRYPOINT ["/app/main"]
main.go
cmd/main.go
main.go
cmd/main.go