forked from docker-library/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-linux.template
128 lines (122 loc) · 3.09 KB
/
Dockerfile-linux.template
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{{
def is_alpine:
env.variant | startswith("alpine")
;
def os_arches:
if is_alpine then
{
amd64: "x86_64",
arm32v6: "armhf",
arm32v7: "armv7",
arm64v8: "aarch64",
i386: "x86",
ppc64le: "ppc64le",
s390x: "s390x",
}
else
{
amd64: "amd64",
arm32v5: "armel",
arm32v7: "armhf",
arm64v8: "arm64",
i386: "i386",
mips64le: "mips64el",
ppc64le: "ppc64el",
s390x: "s390x",
}
end
-}}
{{ if is_alpine then ( -}}
FROM alpine:{{ env.variant | ltrimstr("alpine") }}
{{ ) else ( -}}
FROM debian:{{ env.variant }}-slim
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
# ERROR: no download agent available; install curl, wget, or fetch
curl \
; \
rm -rf /var/lib/apt/lists/*
{{ ) end -}}
ENV JULIA_PATH /usr/local/julia
ENV PATH $JULIA_PATH/bin:$PATH
# https://julialang.org/juliareleases.asc
# Julia (Binary signing key) <[email protected]>
ENV JULIA_GPG 3673DF529D9049477F76B37566E3C7DC03D6E495
# https://julialang.org/downloads/
ENV JULIA_VERSION {{ .version }}
RUN set -eux; \
\
{{ if is_alpine then ( -}}
apk add --no-cache --virtual .fetch-deps gnupg; \
{{ ) else ( -}}
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
gnupg \
; \
rm -rf /var/lib/apt/lists/*; \
{{ ) end -}}
\
# https://julialang.org/downloads/#julia-command-line-version
# https://julialang-s3.julialang.org/bin/checksums/julia-{{ .version }}.sha256
{{ if is_alpine then ( -}}
arch="$(apk --print-arch)"; \
{{ ) else ( -}}
arch="$(dpkg --print-architecture)"; \
{{ ) end -}}
case "$arch" in \
{{
[
.arches
| to_entries[]
| select(.key | if is_alpine then startswith("alpine-") else contains("-") | not end)
| (.key | ltrimstr("alpine-")) as $bashbrewArch
| (os_arches[$bashbrewArch] // empty) as $osArch
| .value
| (
-}}
{{ $osArch | @sh }}) \
url={{ .url | @sh }}; \
sha256={{ .sha256 | @sh }}; \
;; \
{{
)
] | add
-}}
*) \
echo >&2 "error: current architecture ($arch) does not have a corresponding Julia binary release"; \
exit 1; \
;; \
esac; \
\
{{ def wget: if is_alpine then "wget -O" else "curl -fL -o" end -}}
{{ wget }} julia.tar.gz.asc "$url.asc"; \
{{ wget }} julia.tar.gz "$url"; \
\
echo "$sha256 *julia.tar.gz" | sha256sum {{ if is_alpine then "-w -c" else "--strict --check" end }} -; \
\
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$JULIA_GPG"; \
gpg --batch --verify julia.tar.gz.asc julia.tar.gz; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" julia.tar.gz.asc; \
\
mkdir "$JULIA_PATH"; \
tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1; \
rm julia.tar.gz; \
\
{{ if is_alpine then ( -}}
apk del --no-network .fetch-deps; \
{{ ) else ( -}}
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
{{ ) end -}}
\
# smoke test
julia --version
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["julia"]