-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
65 lines (50 loc) · 2.17 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
ARG BUILDIMG=registry.access.redhat.com/ubi9-minimal
ARG RUNIMG=registry.access.redhat.com/ubi9-minimal
# ---------------------------------------
# build image
FROM ${BUILDIMG} AS buildimg
RUN curl -o /etc/yum.repos.d/postgresql.repo \
https://copr.fedorainfracloud.org/coprs/g/insights/postgresql-16/repo/epel-9/group_insights-postgresql-16-epel-9.repo
WORKDIR /vuln4shift
USER root
RUN microdnf install -y golang git-core pg_repack
ADD go.mod /vuln4shift/
ADD go.sum /vuln4shift/
RUN go mod download
ADD main.go /vuln4shift/
ADD base /vuln4shift/base
ADD dbadmin /vuln4shift/dbadmin
ADD manager /vuln4shift/manager
ADD pyxis /vuln4shift/pyxis
ADD digestwriter /vuln4shift/digestwriter
ADD scripts /vuln4shift/scripts
ADD test /vuln4shift/test
ADD vmsync /vuln4shift/vmsync
ADD cleaner /vuln4shift/cleaner
ADD expsync /vuln4shift/expsync
ADD repack /vuln4shift/repack
ARG VERSION=dev
# install swag command to generate swagger
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN mkdir ./manager/docs
RUN bash ./scripts/generate_swagger.sh
RUN go build -ldflags "-X app/manager.Version=$VERSION" -v main.go
# libs to be copied into runtime
RUN mkdir -p /vuln4shift/lib64 && \
ldd /usr/bin/pg_repack \
| awk '/=>/ {print $3}' \
| sort -u \
| while read lib ; do \
ln -v -t /vuln4shift/lib64/ -s $lib ; \
done
# ---------------------------------------
# runtime image
FROM ${RUNIMG} AS runtimeimg
WORKDIR /vuln4shift
USER 1001
COPY --from=buildimg /usr/bin/pg_repack /usr/bin/
COPY --from=buildimg /vuln4shift/lib64/* /lib64/
COPY --from=buildimg /vuln4shift/main /vuln4shift/
COPY --from=buildimg /vuln4shift/dbadmin/migrations /vuln4shift/dbadmin/migrations
COPY --from=buildimg /vuln4shift/manager/docs/swagger.json /vuln4shift/manager/docs/swagger.json
COPY --from=buildimg /vuln4shift/pyxis/profiles.yml /vuln4shift/pyxis/profiles.yml