forked from dgraph-io/travel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile.travel-api
37 lines (31 loc) · 1.14 KB
/
dockerfile.travel-api
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
# Build the Go Binary.
FROM golang:1.14.3 as build_travel-api
ENV CGO_ENABLED 0
ARG VCS_REF
ARG PACKAGE_NAME
ARG PACKAGE_PREFIX
# Create a location in the container for the source code. Using the
# default GOPATH location.
RUN mkdir -p /service
# Copy the source code into the container.
WORKDIR /service
COPY . .
# Build the api binary. We are doing this last since this will be different
# every time we run through this process.
WORKDIR /service/cmd/${PACKAGE_PREFIX}${PACKAGE_NAME}
RUN go build -ldflags "-X main.build=${VCS_REF}"
# Run the Go Binary in Alpine.
FROM alpine:3.7
ARG BUILD_DATE
ARG VCS_REF
ARG PACKAGE_NAME
ARG PACKAGE_PREFIX
COPY --from=build_travel-api /service/cmd/${PACKAGE_PREFIX}${PACKAGE_NAME}/${PACKAGE_NAME} /app/main
WORKDIR /app
CMD ["/app/main"]
LABEL org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.title="${PACKAGE_NAME}" \
org.opencontainers.image.authors="Dgraph" \
org.opencontainers.image.source="https://github.com/dgraph-io/travel/cmd/${PACKAGE_PREFIX}${PACKAGE_NAME}" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.vendor="Dgraph"