-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (32 loc) · 1021 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
FROM golang:1.20-alpine as builder
RUN apk add --no-cache \
# Important: required for go-sqlite3
gcc \
# Required for Alpine
musl-dev \
git \
bash
ENV GO111MODULE=on
ENV CGO_ENABLED=1
ENV GOGC=off
# Add our code
ADD ./ $GOPATH/src/github.com/dewey/paste-my-taste
ADD /web/dist /web/dist
# build
WORKDIR $GOPATH/src/github.com/dewey/paste-my-taste
RUN cd $GOPATH/src/github.com/dewey/paste-my-taste && go build -mod=vendor -v -o /paste-my-taste .
# multistage
FROM alpine:latest
# https://stackoverflow.com/questions/33353532/does-alpine-linux-handle-certs-differently-than-busybox#33353762
RUN apk --update upgrade && \
apk add curl ca-certificates && \
update-ca-certificates && \
rm -rf /var/cache/apk/*
COPY --from=builder /paste-my-taste /usr/bin/paste-my-taste
COPY --from=builder /web/dist /web/dist
# Run the image as a non-root user
RUN adduser -D pmt
RUN chmod 0755 /usr/bin/paste-my-taste
USER pmt
# Run the app. CMD is required to run on Heroku
CMD paste-my-taste