Skip to content

Commit

Permalink
Use separate dockerfile for build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvelsriram committed Jul 24, 2024
1 parent 064c077 commit e3ce981
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
15 changes: 4 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
FROM golang:1.22.5-bookworm as builder

WORKDIR /sftp-exporter
COPY ./go.mod ./
COPY ./go.sum ./
RUN go mod download -x
COPY ./ ./
RUN GOOS=linux GOARCH=$(dpkg --print-architecture) make build

FROM debian:bookworm

WORKDIR /sftp-exporter
COPY --from=builder /sftp-exporter/out/sftp-exporter .
COPY ./sftp-exporter /usr/local/bin/
EXPOSE 8080
RUN useradd -ms /bin/bash sftp-exporter
USER sftp-exporter
ENTRYPOINT ["./sftp-exporter"]
16 changes: 16 additions & 0 deletions build.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM golang:1.22.5-bookworm as builder

WORKDIR /sftp-exporter
COPY ./go.mod ./
COPY ./go.sum ./
RUN go mod download -x
COPY ./ ./
RUN GOOS=linux GOARCH=$(dpkg --print-architecture) make build

FROM debian:bookworm

COPY --from=builder /sftp-exporter/out/sftp-exporter /usr/local/bin/
EXPOSE 8080
RUN useradd -ms /bin/bash sftp-exporter
USER sftp-exporter
ENTRYPOINT ["sftp-exporter"]
2 changes: 1 addition & 1 deletion playground/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ services:
hostname: sftp-exporter
build:
context: ../
dockerfile: ./Dockerfile
dockerfile: ./build.Dockerfile
ports:
- "8081:8080"
environment:
Expand Down

0 comments on commit e3ce981

Please sign in to comment.