-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (33 loc) · 969 Bytes
/
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
FROM golang:1.22 AS builder
WORKDIR /app
RUN apt-get update && \
apt-get install -y libvips-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY go.mod ./
RUN go mod download
COPY . /app
RUN go build -ldflags "-X main.Version=$(cat VERSION | tr -d '\n')" -o ./bin/mediator ./cmd/mediator
# Production stage
FROM ubuntu:latest AS production
RUN apt-get update && \
apt-get install -y libvips-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/bin/mediator .
RUN useradd appuser --create-home --shell /bin/bash && \
chown -R appuser:appuser .
USER appuser:appuser
EXPOSE 8000
CMD ["./mediator"]
# Development stage
FROM builder AS development
ENV GOCACHE=/go/.cache
RUN useradd appuser --create-home --shell /bin/bash && \
chown -R appuser:appuser .
USER appuser:appuser
EXPOSE 8000
CMD ["go", "run", "cmd/mediator/main.go"]