-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (42 loc) · 1.34 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# syntax=docker/dockerfile:1-labs
FROM public.ecr.aws/docker/library/alpine:3.19 AS base
ENV TZ=UTC
WORKDIR /src
# source stage =================================================================
FROM base AS source
# get and extract source from git
ARG BRANCH
ARG VERSION
ADD https://github.com/Cloudbox/autoscan.git#${BRANCH:-v$VERSION} ./
# build stage ==================================================================
FROM base AS build-app
ENV CGO_ENABLED=0
# dependencies
RUN apk add --no-cache git && \
apk add --no-cache go --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
# build dependencies
COPY --from=source /src/go.mod /src/go.sum ./
RUN go mod download
# build app
COPY --from=source /src ./
ARG VERSION
ARG COMMIT=$VERSION
RUN mkdir /build && \
go build -trimpath -ldflags "-s -w \
-X main.Version=$VERSION \
-X main.GitCommit=$COMMIT \
-X main.Timestamp=$(date -u '+%S')" \
-o /build/ ./cmd/...
# runtime stage ================================================================
FROM base
ENV S6_VERBOSITY=0 S6_BEHAVIOUR_IF_STAGE2_FAILS=2 PUID=65534 PGID=65534
WORKDIR /config
VOLUME /config
EXPOSE 3030
# copy files
COPY --from=build-app /build /app
COPY ./rootfs/. /
# runtime dependencies
RUN apk add --no-cache tzdata s6-overlay logrotate curl
# run using s6-overlay
ENTRYPOINT ["/init"]