-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
97 lines (75 loc) · 2.87 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
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
FROM golang:1.21-bullseye as builder
LABEL author="Thomas Bellembois"
ARG BuildID
ENV BuildID=${BuildID}
# Install GCC and git.
# RUN apk add build-base git
# ref. go.mod gochimitheque-wasm
RUN mkdir -p /home/thbellem/workspace \
&& ln -s /go /home/thbellem/workspace/workspace_go
# Installing dependencies.
RUN go install github.com/Joker/jade/cmd/jade@master
#
# Sources.
#
# Getting wasm module sources.
WORKDIR /go/src/github.com/tbellembois/
# sudo mount --bind ~/workspace/workspace_go/src/github.com/tbellembois/gochimitheque-wasm ./bind-gochimitheque-wasm
# sudo mount --bind ~/workspace/workspace_go/src/github.com/tbellembois/gochimitheque-utils ./bind-gochimitheque-utils
COPY ./bind-gochimitheque-wasm ./gochimitheque-wasm
COPY ./bind-gochimitheque-utils ./gochimitheque-utils
# Copying Chimithèque sources.
WORKDIR /go/src/github.com/tbellembois/gochimitheque/
COPY . .
#
# Build.
#
# Building wasm module.
WORKDIR /go/src/github.com/tbellembois/gochimitheque-wasm
RUN GOOS=js GOARCH=wasm go get -v -d ./... \
&& GOOS=js GOARCH=wasm go build -o wasm .
# Copying and compress WASM module into sources.
RUN cp /go/src/github.com/tbellembois/gochimitheque-wasm/wasm /go/src/github.com/tbellembois/gochimitheque/wasm/ \
&& gzip -9 -v -c /go/src/github.com/tbellembois/gochimitheque/wasm/wasm > /go/src/github.com/tbellembois/gochimitheque/wasm/wasm.gz \
&& rm /go/src/github.com/tbellembois/gochimitheque/wasm/wasm
# Installing Chimithèque dependencies.
WORKDIR /go/src/github.com/tbellembois/gochimitheque/
# Generating code.
RUN go generate
# Building Chimithèque.
# docker build --build-arg BuildID=2.0.7 -t tbellembois/gochimitheque:2.0.7 .
RUN if [ -z $BuildID ]; then BuildID=$(date "+%Y%m%d"); fi; echo "BuildID=$BuildID"; go build -ldflags "-X main.BuildID=$BuildID"
#
# Install.
#
FROM golang:1.21-bullseye
RUN rm -Rf /var/cache/apk
# Ensure www-data user exists.
RUN addgroup --gid 82 --system chimitheque \
&& adduser --uid 82 --system --ingroup chimitheque chimitheque \
&& mkdir /data \
&& chown chimitheque /data \
&& chmod 700 /data \
&& mkdir /var/www-data \
&& chown chimitheque /var/www-data \
&& chown chimitheque /var/log \
&& chmod 755 /var/log
COPY --from=builder /go/src/github.com/tbellembois/gochimitheque/gochimitheque /var/www-data/
RUN chown chimitheque /var/www-data/gochimitheque \
&& chmod +x /var/www-data/gochimitheque
#
# Final work.
#
# Copying entrypoint.
COPY docker/entrypoint.sh /
RUN chmod +x /entrypoint.sh
# Adding CA certificates.
ADD docker/terena.crt /usr/local/share/ca-certificates/terena.crt
ADD docker/USERTrust_RSA_Certification_Authority.crt /usr/local/share/ca-certificates/USERTrust_RSA_Certification_Authority.crt
RUN chmod 644 /usr/local/share/ca-certificates/* && update-ca-certificates
# Container configuration.
USER chimitheque
WORKDIR /var/www-data
ENTRYPOINT [ "/entrypoint.sh" ]
VOLUME [ "/data" ]
EXPOSE 8081