-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
38 lines (29 loc) · 951 Bytes
/
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
FROM --platform=${BUILDPLATFORM} golang:alpine AS build
WORKDIR /src
ENV CGO_ENABLED=0
COPY . .
ARG TARGETOS
ARG TARGETARCH
# Set default version, this would be overwrite from GitHub Action
ARG CLOUD_CONNECTOR_VERSION=v0.0
# Build flags
ARG LDFLAGS="-ldflags=-w -s"
ARG OTHERFLAGS="-trimpath -mod=readonly"
ARG VERSION="-X 'main.version=${CLOUD_CONNECTOR_VERSION}'"
RUN echo ${VERSION}
# Build
WORKDIR /src/cmd
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/cloudconnector "${LDFLAGS} ${VERSION}" ${OTHERFLAGS} .
# Set executable flag
RUN chmod +x /src/resources/*.sh
# Final container
FROM busybox AS bin
# Copy binary
COPY --from=build /out/cloudconnector /app/
# Copy default protobuf messages and CA cert
COPY --from=build /src/resources/. /app/
# Create /config dir to be used for custom configuration
RUN mkdir /config
# Execute start script to support ENV variables
WORKDIR /app
CMD ["./cloudconnector_container_start.sh"]