-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
63 lines (46 loc) · 2.28 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
################################################################################
# BUILDER IMAGE
################################################################################
FROM golang:1.24 AS builder
ARG VERSION
# ------------------------------------------------------------------------------
# Define and create working directory
# ------------------------------------------------------------------------------
ENV APP_HOME=/app
RUN mkdir -p ${APP_HOME}
WORKDIR ${APP_HOME}
# ------------------------------------------------------------------------------
# Copy source code
# ------------------------------------------------------------------------------
COPY . .
# ------------------------------------------------------------------------------
# Build
# ------------------------------------------------------------------------------
RUN CGO_ENABLED=0 go build -a -o /outerspace-go \
-ldflags "-s -w -X main.Version=${VERSION} -X main.BuildTime=$(TZ=UTC date +%Y-%m-%dT%H:%M:%S%z)"
################################################################################
# RELEASE IMAGE
################################################################################
FROM docker.io/bitnami/minideb:buster
# ------------------------------------------------------------------------------
# Install persistent dependencies
# ------------------------------------------------------------------------------
ENV PERSISTENT_DEPS="curl ca-certificates"
RUN install_packages ${PERSISTENT_DEPS}
# ------------------------------------------------------------------------------
# Define working directory & user
# ------------------------------------------------------------------------------
ENV APP_HOME=/app
ARG APP_USER=1001
WORKDIR ${APP_HOME}
# ------------------------------------------------------------------------------
# Copy built application
# ------------------------------------------------------------------------------
COPY --from=builder --chown=${APP_USER} /outerspace-go ./outerspace-go
RUN chmod +x ./outerspace-go
# ------------------------------------------------------------------------------
# Define user, exposed ports, additional env vars, entrypoint and cmd
# ------------------------------------------------------------------------------
USER ${APP_USER}
EXPOSE 8443 8080
CMD ["/app/outerspace-go"]