Skip to content

Commit d2b5968

Browse files
committed
chore: add basic Dockerfile
1 parent 88628a0 commit d2b5968

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM golang:alpine AS builder
2+
WORKDIR /app
3+
4+
RUN apk add --no-cache git bash
5+
6+
COPY go.mod go.sum ./
7+
RUN go mod download
8+
9+
COPY . .
10+
11+
ARG BUILT_AT
12+
ARG GIT_COMMIT
13+
ARG VERSION
14+
15+
RUN builtAt=${BUILT_AT:-$(date +'%F %T %z')} && \
16+
gitCommit=${GIT_COMMIT:-$(git log --pretty=format:"%h" -1)} && \
17+
version=${VERSION:-$(git describe --abbrev=0 --tags)} && \
18+
ldflags="\
19+
-w -s \
20+
-X 'github.com/krau/ManyACG/common.BuildTime=$builtAt' \
21+
-X 'github.com/krau/ManyACG/common.Commit=$gitCommit' \
22+
-X 'github.com/krau/ManyACG/common.Version=$version'\
23+
" && \
24+
CGO_ENABLED=0 go build -ldflags "$ldflags" -o manyacg
25+
26+
FROM alpine:latest
27+
WORKDIR /opt/manyacg/
28+
29+
RUN apk add --no-cache bash ca-certificates ffmpeg && update-ca-certificates
30+
31+
COPY --from=builder /app/manyacg .
32+
33+
EXPOSE 39080
34+
ENTRYPOINT ["./manyacg"]

build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
builtAt="$(date +'%F %T %z')"
2+
gitCommit=$(git log --pretty=format:"%h" -1)
3+
version=$(git describe --abbrev=0 --tags)
4+
5+
ldflags="\
6+
-w -s \
7+
-X 'github.com/krau/ManyACG/common.BuildTime=$builtAt' \
8+
-X 'github.com/krau/ManyACG/common.Commit=$gitCommit' \
9+
-X 'github.com/krau/ManyACG/common.Version=$version'\
10+
"
11+
12+
CGO_ENABLED=0 go build -ldflags "$ldflags" -o manyacg

0 commit comments

Comments
 (0)