-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
61 lines (46 loc) · 1.97 KB
/
Copy pathDockerfile
File metadata and controls
61 lines (46 loc) · 1.97 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
57
58
59
60
61
# ---------- Stage 1: Build ----------
FROM golang:1.23-bookworm AS builder
WORKDIR /app
ENV CGO_ENABLED=1
# Install build tools and gfortran runtime for linking
RUN apt-get update && apt-get install -y build-essential gfortran
# Copy source code
COPY . .
RUN go mod download
# Build metadata
ARG VERSION
ARG COMMIT
ARG BUILD
# Install SGP4 libraries and license file for tests and runtime
RUN cp /app/internal/dllcore/_lib/*.so /usr/local/lib/ 2>/dev/null || true && \
cp /app/internal/dllcore/_lib/SGP4_Open_License.txt /usr/local/lib/ 2>/dev/null || true && \
cp /app/internal/dllcore/_lib/SGP4_Open_License.txt /app/ 2>/dev/null || true && \
cp /app/internal/dllcore/_lib/SGP4_Open_License.txt /app/scripts/ 2>/dev/null || true && \
cp /app/internal/dllcore/_lib/SGP4_Open_License.txt /app/internal/core/ 2>/dev/null || true && \
cp /app/internal/dllcore/_lib/SGP4_Open_License.txt /app/internal/core/gc/ 2>/dev/null || true && \
ldconfig
# Run tests
WORKDIR /app/scripts
RUN bash ./run_unit_tests_config.sh
RUN bash ./run_unit_tests_gc.sh
RUN bash ./run_integration_tests_core.sh
WORKDIR /app
# Build Go binary
RUN go build -ldflags="-s -w \
-X github.com/xpropagation/xpropagator/internal/values.Version=${VERSION} \
-X github.com/xpropagation/xpropagator/internal/values.CommitHash=${COMMIT} \
-X github.com/xpropagation/xpropagator/internal/values.BuildDate=${BUILD}" \
-o bin/xpropagator .
# ---------- Stage 2: Runtime ----------
FROM debian:bookworm-slim
WORKDIR /app
# Install Fortran runtime for execution
RUN apt-get update && apt-get install -y libgfortran5 && rm -rf /var/lib/apt/lists/*
# Copy Go binary and shared libraries from builder
COPY --from=builder /app/bin/xpropagator .
COPY --from=builder /app/internal/dllcore/_lib/SGP4_Open_License.txt .
COPY --from=builder /app/config/cfg_default.yaml ./cfg.yaml
COPY --from=builder /app/internal/dllcore/_lib/ /usr/local/lib/
ENV SERVICE_CONFIG=cfg.yaml
RUN ldconfig
ENTRYPOINT ["./xpropagator"]