-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathDockerfile.superadmin
More file actions
56 lines (44 loc) · 1.72 KB
/
Dockerfile.superadmin
File metadata and controls
56 lines (44 loc) · 1.72 KB
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
FROM golang:1.24.10-alpine AS base
ARG JUST_VERSION=1.46.0
RUN apk update && apk upgrade
RUN apk add --no-cache tzdata git curl bash ca-certificates && update-ca-certificates && \
arch="$(apk --print-arch)" && \
case "$arch" in \
x86_64) target="x86_64-unknown-linux-musl" ;; \
aarch64) target="aarch64-unknown-linux-musl" ;; \
*) echo "Unsupported arch for just: $arch" ; exit 1 ;; \
esac && \
curl -sSfL "https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${target}.tar.gz" \
| tar -xz -C /usr/local/bin just && \
chmod +x /usr/local/bin/just && \
just --version
WORKDIR /build
ENV GO111MODULE=auto \
CGO_ENABLED=0 \
GOOS=linux
COPY scripts/install.sh .
RUN chmod +x install.sh && bash ./install.sh
FROM base AS build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN just css
RUN go build -o run_superadmin cmd/superadmin/main.go && \
go build -o command cmd/command/main.go && \
go build -o collect_logs cmd/collect-logs/main.go
# Default final base image to Alpine Linux
FROM alpine:3.21 AS production
# Ensure we have latest packages applied
RUN apk update && apk upgrade
# Create a non-root user
RUN addgroup -g 10001 -S iota-user \
&& adduser --disabled-password --gecos '' -u 10000 --home /home/iota-user iota-user -G iota-user \
&& chown -R iota-user:iota-user /home/iota-user
WORKDIR /home/iota-user
COPY --from=build /build/run_superadmin ./run_superadmin
COPY --from=build /build/command ./command
COPY --from=build /build/collect_logs ./collect_logs
COPY --from=build /build/migrations ./migrations
ENV PATH=/home/iota-user:$PATH
USER iota-user
CMD ["/bin/sh", "-c", "collect_logs & command migrate up && run_superadmin"]