-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.Dockerfile
executable file
·112 lines (82 loc) · 2.96 KB
/
package.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -----------------------------------------------------------------------------
# Stages
# -----------------------------------------------------------------------------
ARG IMAGE_BUILDER=golang:1.23.4-bookworm
ARG IMAGE_FPM=dockter/fpm:latest
ARG IMAGE_FINAL=alpine
# -----------------------------------------------------------------------------
# Stage: builder
# -----------------------------------------------------------------------------
FROM ${IMAGE_BUILDER} AS builder
ENV REFRESHED_AT=2024-07-01
LABEL Name="senzing/go-builder" \
Maintainer="support@senzing.com" \
Version="0.1.0"
# Build arguments.
ARG PROGRAM_NAME="unknown"
ARG BUILD_VERSION=0.0.0
ARG BUILD_ITERATION=0
ARG GO_PACKAGE_NAME="unknown"
# Copy local files from the Git repository.
COPY ./rootfs /
COPY . ${GOPATH}/src/${GO_PACKAGE_NAME}
# Build go program.
WORKDIR ${GOPATH}/src/${GO_PACKAGE_NAME}
RUN make linux/amd64
# Copy binaries to /output.
RUN mkdir -p /output \
&& cp -R ${GOPATH}/src/${GO_PACKAGE_NAME}/target/* /output/
# -----------------------------------------------------------------------------
# Stage: fpm
# - Reference: https://github.com/jordansissel/fpm/blob/master/Dockerfile
# - FPM: https://fpm.readthedocs.io/en/latest/cli-reference.html
# -----------------------------------------------------------------------------
FROM ${IMAGE_FPM} AS fpm
ENV REFRESHED_AT=2024-07-01
LABEL Name="senzing/fpm-builder" \
Maintainer="support@senzing.com" \
Version="0.1.0"
# Use arguments from prior stage.
ARG PROGRAM_NAME
ARG BUILD_VERSION
ARG BUILD_ITERATION
ARG GO_PACKAGE_NAME
# Copy files from prior stage.
COPY --from=builder "/output/linux-amd64/*" "/output/linux-amd64/"
# Create Linux RPM package.
RUN fpm \
--input-type dir \
--output-type rpm \
--name ${PROGRAM_NAME} \
--package /output/${PROGRAM_NAME}-${BUILD_VERSION}.rpm \
--version ${BUILD_VERSION} \
--iteration ${BUILD_ITERATION} \
/output/linux-amd64/=/usr/bin
# Create Linux DEB package.
RUN fpm \
--deb-no-default-config-files \
--input-type dir \
--iteration ${BUILD_ITERATION} \
--name ${PROGRAM_NAME} \
--output-type deb \
--package /output/${PROGRAM_NAME}-${BUILD_VERSION}.deb \
--version ${BUILD_VERSION} \
/output/linux-amd64/=/usr/bin
# -----------------------------------------------------------------------------
# Stage: final
# -----------------------------------------------------------------------------
FROM ${IMAGE_FINAL} AS final
ENV REFRESHED_AT=2024-07-01
LABEL Name="senzing/final-stage" \
Maintainer="support@senzing.com" \
Version="0.1.0"
HEALTHCHECK CMD ["/app/healthcheck.sh"]
# Copy files from repository.
COPY ./rootfs /
# Use arguments from prior stage.
ARG PROGRAM_NAME
# Copy files from prior step.
COPY --from=fpm "/output/*" "/output/"
COPY --from=fpm "/output/linux-amd64/${PROGRAM_NAME}" "/output/linux-amd64/${PROGRAM_NAME}"
USER 1001
CMD ["/bin/bash"]