-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (60 loc) · 1.99 KB
/
Dockerfile
File metadata and controls
75 lines (60 loc) · 1.99 KB
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
73
74
75
# global arguments
ARG TZ_ARG
ARG AUTHOR
ARG VERSION
ARG TAG
ARG BUILD_TIME
ARG RUN_NUMBER
FROM uzie17/debian:stable-Jakarta AS base
LABEL maintainer="Muhammad Febrian Ardiansyah <mfardiansyah.id@gmail.com>"
WORKDIR /app
ARG TZ_ARG
# CERT PACKAGES
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN apt-get update && \
apt-get install -yq tzdata && \
ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata
ENV TZ=$TZ_ARG
#FROM repository.konsulin.care/repository/private/be-konsulin:latest as gobuild
FROM konsulin/rest-backend-vendor:develop AS gobuild
LABEL stage=gobuild
# captures argument
ARG GIT_COMMIT
# e.g. latest, development, production
ARG VERSION=latest
ARG BUILD_TIME
ARG TAG
ARG TZ_ARG
ARG AUTHOR
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GO111MODULE=on
RUN echo "Set ARG value of [AUTHOR] as AUTHOR"
RUN echo "Set ARG value of [GIT_COMMIT] as $GIT_COMMIT"
RUN echo "Set ARG value of [VERSION] as $VERSION"
RUN echo "Set ARG value of [BUILD_TIME] as $BUILD_TIME"
RUN echo "Set ARG value of [TAG] as $TAG"
# get current commit and create build number
ARG RELEASE_NOTE="author=$AUTHOR \nversion=$VERSION \ncommit=${GIT_COMMIT} \ntag=$TAG \nbuild time=$BUILD_TIME \nrun number=$RUN_NUMBER"
RUN echo "${RELEASE_NOTE}" > /go/src/github.com/konsulin-id/be-konsulin/RELEASE
ADD . ./
ADD go.mod go.sum ./
ADD cmd ./cmd
ADD cmd/http ./cmd/http
#ADD cmd/example ./cmd/example
ADD internal ./internal
ADD pkg ./pkg
# updates vendor
RUN go mod tidy && go mod vendor
# builds
RUN go build -o api-service \
-ldflags "-X main.Version=$VERSION -X main.Tag=$TAG" \
/go/src/github.com/konsulin-id/be-konsulin/cmd/http
# /go/src/github.com/konsulin-id/be-konsulin/cmd/example
FROM base AS release
COPY --from=gobuild /go/src/github.com/konsulin-id/be-konsulin/ .
# COPY --from=gobuild /go/src/github.com/konsulin-id/be-konsulin/api-service .
# COPY --from=gobuild /go/src/github.com/konsulin-id/be-konsulin/RELEASE ./RELEASE
ENTRYPOINT ["./api-service"]