forked from spiffe/tornjak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.backend-container.ubi
54 lines (47 loc) · 1.77 KB
/
Dockerfile.backend-container.ubi
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
# xx is helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.3.0 AS xx
FROM --platform=$BUILDPLATFORM golang:1.22-alpine3.19 AS builder
RUN apk add build-base
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
COPY --link --from=xx / /
ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=1
RUN apk add clang lld
RUN make vendor
RUN xx-go --wrap
RUN xx-apk add musl-dev gcc
RUN if [ "$TARGETARCH" = "arm64" ]; then CC=aarch64-alpine-linux-musl; fi && \
go build --tags 'sqlite_json' -mod=vendor -ldflags '-s -w -linkmode external -extldflags "-static"' -o bin/tornjak-backend ./cmd/agent/main.go
FROM registry.access.redhat.com/ubi8-micro:latest AS runtime
RUN mkdir -p /opt/tornjak
WORKDIR /opt/tornjak
ENTRYPOINT ["/opt/tornjak/run_backend.sh"]
# Add init
COPY scripts/run_backend.sh run_backend.sh
COPY --from=builder /usr/src/myapp/bin/tornjak-backend tornjak-backend
# add a version link to the image description
ARG version
ARG github_sha
LABEL org.opencontainers.image.description="Tornjak backend ($version) UBI based image: https://github.com/spiffe/tornjak/releases/tag/$version" \
org.opencontainers.image.source="https://github.com/spiffe/tornjak" \
org.opencontainers.image.documentation="https://github.com/spiffe/tornjak/tree/main/docs"
# replace UBI labels
LABEL architecture="amd64" \
build-date="" \
description="Tornjak Backend" \
io.k8s.description="Tornjak Backend" \
io.k8s.display-name="tornjak-backend" \
maintainer="" \
name="spiffe/tornjak-backend" \
release="$version" \
summary="Tornjak backend UBI image" \
url="" \
vcs-ref="" \
vcs-type="" \
vendor="" \
version="$version"
# create env. variables with the build details
ENV VERSION=$version
ENV GITHUB_SHA=$github_sha