-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile
43 lines (29 loc) · 1.08 KB
/
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
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.21
ARG REPO=github.com/LiterMC/go-openbmclapi
ARG NPM_DIR=dashboard
FROM node:21 AS WEB_BUILD
ARG NPM_DIR
WORKDIR /web/
COPY ["${NPM_DIR}/package.json", "${NPM_DIR}/package-lock.json", "/web/"]
RUN --mount=type=cache,target=/root/.npm/_cacache \
npm ci --progress=false || { cat /root/.npm/_logs/*; exit 1; }
COPY ["${NPM_DIR}", "/web/"]
RUN npm run build || { cat /root/.npm/_logs/*; exit 1; }
FROM golang:${GO_VERSION}-alpine AS BUILD
ARG TAG
ARG REPO
ARG NPM_DIR
WORKDIR "/go/src/${REPO}/"
COPY ./go.mod ./go.sum "/go/src/${REPO}/"
RUN go mod download
COPY . "/go/src/${REPO}"
COPY --from=WEB_BUILD "/web/dist" "/go/src/${REPO}/${NPM_DIR}/dist"
ENV ldflags="-X 'github.com/LiterMC/go-openbmclapi/internal/build.BuildVersion=$TAG'"
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -v -o "/go/bin/go-openbmclapi" -ldflags="$ldflags" "."
FROM alpine:latest
WORKDIR /opt/openbmclapi
COPY ./config.yaml /opt/openbmclapi/config.yaml
COPY --from=BUILD "/go/bin/go-openbmclapi" "/go-openbmclapi"
CMD ["/go-openbmclapi"]