Skip to content

Commit d52533b

Browse files
committed
Update dockerfile to install security updates
Plus hacks to build the binary in the dockerfile as it is a bit of a pain to build the older style project with newer go tooling.
1 parent 74d8d5e commit d52533b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

Dockerfile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
FROM debian:10-slim
1+
FROM golang:1.20.4 AS builder
2+
3+
COPY . ./src/github.com/NextDeveloperTeam/postgres_exporter
4+
5+
WORKDIR /go/src/github.com/NextDeveloperTeam/postgres_exporter
6+
7+
RUN GO111MODULE=off go run mage.go binary \
8+
&& cp ./bin/postgres_exporter_v0.8.0_linux-amd64/postgres_exporter /postgres_exporter
9+
10+
FROM debian:11-slim
211
RUN useradd -u 20001 postgres_exporter
312

413
# Install certs and create home directory needed by the AWS SDK
5-
RUN apt update && apt install ca-certificates -y \
14+
RUN apt-get update && apt-get upgrade -y && apt install ca-certificates -y \
615
&& mkdir /home/postgres_exporter \
716
&& chown postgres_exporter:postgres_exporter /home/postgres_exporter \
817
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
918

1019
USER postgres_exporter
1120

12-
ARG binary
13-
14-
COPY $binary /postgres_exporter
21+
COPY --chown=postgres_exporter:postgres_exporter --from=builder /postgres_exporter /postgres_exporter
1522

1623
EXPOSE 9187
1724

0 commit comments

Comments
 (0)