This repository has been archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
72 lines (57 loc) · 2.57 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
# SPDX-License-Identifier: MIT
###############################################################################
# SET UP BUILD-ENV
###############################################################################
FROM golang:1.14 as build-env
ARG TASK_VERSION=2.8.0
# Install Task
WORKDIR /tmp
RUN curl -fsSLo task.tgz https://github.com/go-task/task/releases/download/v${TASK_VERSION}/task_linux_amd64.tar.gz && \
mkdir -p task && \
tar xvf task.tgz -C task && \
mv task/task /usr/local/bin/ && \
rm -rf task*
WORKDIR /workdir
COPY go.mod go.mod
COPY go.sum go.sum
COPY ./tasks/BuildTasks.yml Taskfile.yml
RUN task prepare
###############################################################################
# BUILD
###############################################################################
FROM build-env as build
ARG GO_BUILD_ENV="GOOS=linux GOARCH=amd64 CGO_ENABLED=0"
COPY pkg/controllers pkg/controllers/
COPY pkg/util pkg/util/
COPY main.go main.go
RUN task build GO_BUILD_ENV="${GO_BUILD_ENV}"
###############################################################################
# TEST
###############################################################################
FROM build as test
RUN task test
###############################################################################
# FINAL IMAGE
###############################################################################
FROM alpine:latest
ARG BUILD_DATE
ARG VCS_REF
ARG BUILD_VERSION
LABEL com.daimler.namespace-provisioner.license="MIT" \
com.daimler.namespace-provisioner.license-url="https://github.com/Daimler/namespace-provisioner/blob/master/LICENSE" \
org.opencontainers.image.authors="Daimler TSS GmbH" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.description="A Kubernetes operator creating K8s resources by annotating namespaces." \
org.opencontainers.image.documentation="https://github.com/Daimler/namespace-provisioner/blob/master/README.md" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision="${VCS_REF}" \
org.opencontainers.image.source="https://github.com/Daimler/namespace-provisioner.git" \
org.opencontainers.image.title="Namespace Provisioner" \
org.opencontainers.image.url="https://github.com/Daimler/namespace-provisioner" \
org.opencontainers.image.vendor="Daimler TSS GmbH" \
org.opencontainers.image.version="${BUILD_VERSION}"
USER 100
WORKDIR /app
COPY --chown=100:100 --from=build /workdir/build/bin/namespace-provisioner .
COPY LICENSE /LICENSE
ENTRYPOINT ["./namespace-provisioner"]