-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
70 lines (52 loc) · 1.58 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# syntax=docker/dockerfile:1.4
ARG repo=ghcr.io/momentum-xyz/
ARG version_ui=develop
ARG LDFLAGS="-s -w"
ARG BUILD_VERSION
###############
# Build stage #
###############
FROM golang:1.20-alpine3.17 as build
ARG BUILD_VERSION
RUN apk add --update --no-cache gcc make binutils-gold musl-dev
WORKDIR /project
ENV GOPATH /go
ENV GOCACHE /go-cache
# Seperate step to allow docker layer caching
COPY go.* ./
RUN --mount=type=cache,target=/go/pkg/mod/cache \
go mod download
COPY . ./
# extra ldflag to make sure it works with alpine/musl
ARG LDFLAGS
ENV LDFLAGS="$LDFLAGS -extldflags '-fuse-ld=bfd'" BUILD_VERSION=${BUILD_VERSION}
RUN --mount=type=cache,target=/go/pkg/mod/cache \
--mount=type=cache,target=/go-build \
make build
##################
# Runtime target #
##################
FROM alpine:3.16 as runtime
LABEL org.opencontainers.image.source=https://github.com/momentum-xyz/ubercontroller
LABEL org.opencontainers.image.description="Controller of Odyssey Momentum"
LABEL org.opencontainers.image.licenses=AGPL-3.0-only
COPY --link ./seed/data /srv/seed/data
COPY --link ./fonts /srv/fonts
COPY --from=build /project/bin/ubercontroller /srv/ubercontroller
WORKDIR /srv
EXPOSE 4000
CMD ["/srv/ubercontroller"]
##################
# Frontend image #
##################
FROM ${repo}ui-client:${version_ui} as ui-client
######################
# Embedded UI target #
######################
FROM runtime as monolith
env FRONTEND_SERVE_DIR=/srv/ui
COPY --from=ui-client --link /opt/srv /srv/ui
########################
# Default build target #
########################
FROM runtime as default