Skip to content

Commit 64369c0

Browse files
v2: add Dockerfile
Signed-off-by: Ricky Moorhouse <[email protected]>
1 parent 6ae6338 commit 64369c0

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

Dockerfile

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
FROM registry.access.redhat.com/ubi8/ubi-minimal
2-
RUN microdnf install -y python3 python3-devel redhat-rpm-config gcc libffi-devel openssl-devel cargo
3-
WORKDIR /app
4-
COPY ./requirements.txt /app/
5-
RUN python3 -m pip install setuptools_rust
6-
RUN python3 -m pip install -r /app/requirements.txt
7-
COPY *.py /app/
8-
COPY test-assets /app/test-assets
9-
# Create and set user
10-
RUN adduser -D trawler -u 1000
11-
RUN chown -R trawler:users /app
12-
USER 1000
13-
ENV APP_FILE=/app/trawler.py
14-
CMD ["python3", "/app/trawler.py", "-c", "/app/config/config.yaml"]
1+
FROM registry.access.redhat.com/ubi9/ubi-minimal AS build
2+
RUN microdnf update -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 && \
3+
microdnf install -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 zip unzip make git gcc && \
4+
microdnf install -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 go-toolset ca-certificates && \
5+
microdnf clean all && \
6+
rm -rf /var/cache/yum
7+
WORKDIR /app/
8+
9+
ENV GOPATH /tmp/go
10+
ENV PATH $PATH:$GOPATH/bin
11+
12+
COPY . .
13+
RUN go mod download
14+
15+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./out/trawler .
16+
17+
FROM registry.access.redhat.com/ubi9/ubi-minimal
18+
19+
ARG USER_UID
20+
ARG USER_NAME
21+
22+
ENV USER_UID ${USER_UID:-1001}
23+
ENV USER_NAME ${USER_NAME:-apic}
24+
RUN mkdir -p ${HOME} && chown ${USER_UID}:0 ${HOME} && chmod ug+rwx ${HOME}
25+
26+
COPY --from=build /app/out/trawler /app/trawler
27+
COPY base-config.yaml /app/config/config.yaml
28+
29+
USER root
30+
RUN microdnf upgrade -y --refresh --best --nodocs --noplugins --setopt=install_weak_deps=0 \
31+
&& microdnf clean all
32+
USER 1001:0
33+
34+
EXPOSE 63512
35+
ENV CONFIG_PATH=/app/config/config.yaml
36+
37+
CMD ["/app/trawler"]

0 commit comments

Comments
 (0)