-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (58 loc) · 2.95 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
ARG ALPINE_VERSION=3
ARG GO_VERSION=1.21
FROM alpine:${ALPINE_VERSION} AS certificator
RUN apk --update add --no-cache ca-certificates openssl git tzdata && \
update-ca-certificates
FROM golang:${GO_VERSION}-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG UNCONDITIONAL_API_BUILD_COMMIT_VERSION
ARG UNCONDITIONAL_API_BUILD_RELEASE_VERSION
ENV CGO_ENABLED=0
ENV UNCONDITIONAL_API_BUILD_COMMIT_VERSION=${UNCONDITIONAL_API_BUILD_COMMIT_VERSION}
ENV UNCONDITIONAL_API_BUILD_RELEASE_VERSION=${UNCONDITIONAL_API_BUILD_RELEASE_VERSION}
RUN go build --ldflags "-X 'main.releaseVersion=${UNCONDITIONAL_API_BUILD_RELEASE_VERSION}' -X 'main.gitCommit=${UNCONDITIONAL_API_BUILD_COMMIT_VERSION}'" --tags=release -o main .
FROM builder as data
WORKDIR /data
COPY --from=builder /app/main /app/main
ARG UNCONDITIONAL_API_SOURCE_REPO
ARG UNCONDITIONAL_API_SOURCE_CLIENT_KEY
ARG UNCONDITIONAL_API_FEED_REPO_HOST
ARG UNCONDITIONAL_API_FEED_REPO_KEY
ARG UNCONDITIONAL_API_LOG_ENV
ENV UNCONDITIONAL_API_SOURCE_REPO=${UNCONDITIONAL_API_SOURCE_REPO}
ENV UNCONDITIONAL_API_SOURCE_CLIENT_KEY=${UNCONDITIONAL_API_SOURCE_CLIENT_KEY}
ENV UNCONDITIONAL_API_FEED_REPO_HOST=${UNCONDITIONAL_API_FEED_REPO_HOST}
ENV UNCONDITIONAL_API_FEED_REPO_KEY=${UNCONDITIONAL_API_FEED_REPO_KEY}
ENV UNCONDITIONAL_API_LOG_ENV=${UNCONDITIONAL_API_LOG_ENV}
RUN --mount=type=secret,id=UNCONDITIONAL_API_SOURCE_CLIENT_KEY \
--mount=type=secret,id=UNCONDITIONAL_API_FEED_REPO_HOST \
--mount=type=secret,id=UNCONDITIONAL_API_FEED_REPO_INDEX \
--mount=type=secret,id=UNCONDITIONAL_API_FEED_REPO_KEY \
UNCONDITIONAL_API_SOURCE_CLIENT_KEY="$(cat /run/secrets/UNCONDITIONAL_API_SOURCE_CLIENT_KEY)" \
UNCONDITIONAL_API_FEED_REPO_HOST="$(cat /run/secrets/UNCONDITIONAL_API_FEED_REPO_HOST)" \
UNCONDITIONAL_API_FEED_REPO_KEY="$(cat /run/secrets/UNCONDITIONAL_API_FEED_REPO_KEY)" \
/app/main index create --name feeds
FROM scratch as release
COPY --from=certificator /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/main /app/main
COPY --from=data /data /data
ARG UNCONDITIONAL_API_ADDRESS
ARG UNCONDITIONAL_API_ALLOWED_ORIGINS
ARG UNCONDITIONAL_API_PORT
ARG UNCONDITIONAL_API_SOURCE_REPO
ARG UNCONDITIONAL_API_SOURCE_CLIENT_KEY
ARG UNCONDITIONAL_API_LOG_ENV
ARG UNCONDITIONAL_API_FEED_REPO_HOST
ARG UNCONDITIONAL_API_FEED_REPO_KEY
ENV UNCONDITIONAL_API_ADDRESS=${UNCONDITIONAL_API_ADDRESS}
ENV UNCONDITIONAL_API_ALLOWED_ORIGINS=${UNCONDITIONAL_API_ALLOWED_ORIGINS}
ENV UNCONDITIONAL_API_PORT=${UNCONDITIONAL_API_PORT}
ENV UNCONDITIONAL_API_SOURCE_REPO=${UNCONDITIONAL_API_SOURCE_REPO}
ENV UNCONDITIONAL_API_SOURCE_CLIENT_KEY=${UNCONDITIONAL_API_SOURCE_CLIENT_KEY}
ENV UNCONDITIONAL_API_LOG_ENV=${UNCONDITIONAL_API_LOG_ENV}
ENV UNCONDITIONAL_API_FEED_REPO_HOST=${UNCONDITIONAL_API_FEED_REPO_HOST}
ENV UNCONDITIONAL_API_FEED_REPO_KEY=${UNCONDITIONAL_API_FEED_REPO_KEY}
ENTRYPOINT ["./app/main","serve", "--address", "0.0.0.0", "--port","8080","--feed-repo-index","feeds"]