-
Notifications
You must be signed in to change notification settings - Fork 36
/
Dockerfile
40 lines (30 loc) · 872 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
# Build UI
FROM node:alpine3.18 as build-ui
WORKDIR /build
COPY ui/package.json .
COPY ui/yarn.lock .
RUN yarn
COPY ui/. .
RUN yarn build
# Build API
FROM golang:alpine3.18 AS build-api
RUN apk add --no-cache --update openssh-client git make
ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GOARCH=amd64
SHELL ["/bin/ash", "-c"]
# Setup SSH for private repos
RUN mkdir -m 0700 ~/.ssh \
&& ssh-keyscan github.com >> ~/.ssh/known_hosts \
&& git config --global url."git@github.com:".insteadOf "https://github.com/"
WORKDIR /build
COPY . .
# Embed the UI
COPY --from=build-ui /build/dist/. embed/public_html
RUN --mount=type=ssh make
FROM alpine:3.18
RUN apk add --no-cache --update tzdata ca-certificates su-exec
# Copy the executable
WORKDIR /app
COPY --from=build-api /build/build/gorestapi /app/gorestapi
ENTRYPOINT [ "su-exec", "nobody:nobody", "/app/gorestapi" ]