This repository has been archived by the owner on Apr 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
70 lines (52 loc) · 2.53 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
# Copyright (C) 2020, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
# Provide promtool binary from the prometheus image
FROM ghcr.io/verrazzano/prometheus:v2.13.1-3 AS build_base_prometheus
FROM ghcr.io/oracle/oraclelinux:7-slim AS build_base
RUN yum-config-manager --enable ol7_optional_latest && \
yum-config-manager --enable ol7_addons
RUN yum update -y \
&& yum-config-manager --save --setopt=ol7_ociyum_config.skip_if_unavailable=true \
&& yum install -y oracle-golang-release-el7 \
&& yum-config-manager --add-repo http://yum.oracle.com/repo/OracleLinux/OL7/developer/golang113/x86_64 \
&& yum install -y git gcc make golang-1.13.3-1.el7 \
&& yum clean all \
&& go version
# Cirith uses go modules, so don't need to be in ~/go/src
WORKDIR /go/src/github.com/verrazzano/verrazzano-monitoring-instance-api
# Compile to /usr/bin
ENV GOBIN=/usr/bin
# Set go path
ENV GOPATH=/go
RUN mkdir -p /go/bin
RUN curl -o /go/bin/swagger -L'#' https://github.com/go-swagger/go-swagger/releases/download/v0.20.1/swagger_linux_amd64
RUN chmod +x /go/bin/swagger
COPY . .
# Copy promtool from Prometheus build images
COPY --from=build_base_prometheus /bin/promtool /opt/tools/bin/promtool
ENV CGO_ENABLED 0
ENV GO111MODULE on
RUN go test -tags=integration -v ./handlers/...
RUN go build -o /usr/bin/cirith cmd/cirith/main.go
ENV GOROOT /usr/lib/golang
RUN /go/bin/swagger generate spec -o ./static/cirith.json ./...
FROM ghcr.io/oracle/oraclelinux:7-slim AS final
RUN yum-config-manager --enable ol7_optional_latest && \
yum-config-manager --enable ol7_addons
RUN yum update -y && \
yum-config-manager --enable ol7_u8_security_validation \
&& yum install -y openssl \
&& yum install -y ca-certificates curl && yum clean all && rm -rf /var/cache/yum
# Add cirith user/group
RUN groupadd -r cirith && useradd --no-log-init -r -g cirith -u 1000 cirith
# Copy static assets from base stage build context
COPY --from=build_base /go/src/github.com/verrazzano/verrazzano-monitoring-instance-api/static /usr/local/bin/static
COPY --from=build_base /usr/bin/cirith /usr/local/bin/cirith
# Copy promtool from base stage build context
COPY --from=build_base /opt/tools/bin/promtool /opt/tools/bin/promtool
# Set perms as tight as possible
RUN chown -R cirith:cirith /usr/local/bin/* /opt/tools/bin/* \
&& chmod 500 /usr/local/bin/* /opt/tools/bin/*
# K8s requires numeric UID to discern between root and non-root
USER 1000
ENTRYPOINT ["/usr/local/bin/cirith"]