Skip to content

Commit 00fc86e

Browse files
fix: add ARM docker support (#49)
Closes #48
1 parent 33db568 commit 00fc86e

File tree

2 files changed

+49
-56
lines changed

2 files changed

+49
-56
lines changed

Dockerfile

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
1-
FROM openjdk:12-alpine
1+
FROM openjdk:16-slim-buster
22

3-
RUN apk add --no-cache \
4-
ca-certificates
5-
6-
# set up nsswitch.conf for Go's "netgo" implementation
7-
# - https://github.com/golang/go/blob/go1.9.1/src/net/conf.go#L194-L275
8-
# - docker run --rm debian:stretch grep '^hosts:' /etc/nsswitch.conf
9-
RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
3+
RUN apt-get update; apt-get install -y --no-install-recommends ca-certificates
104

115
ENV GOLANG_VERSION 1.15.6
126

137
RUN set -eux; \
14-
apk add --no-cache --virtual .build-deps \
15-
bash \
16-
gcc \
17-
musl-dev \
18-
openssl \
19-
go \
20-
; \
8+
apt-get install -y --no-install-recommends bash build-essential openssl golang-go curl wget; \
9+
rm -rf /var/lib/apt/lists/*; \
2110
export \
22-
# set GOROOT_BOOTSTRAP such that we can actually build Go
23-
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
24-
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
25-
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
26-
GOOS="$(go env GOOS)" \
27-
GOARCH="$(go env GOARCH)" \
28-
GOHOSTOS="$(go env GOHOSTOS)" \
29-
GOHOSTARCH="$(go env GOHOSTARCH)" \
11+
# set GOROOT_BOOTSTRAP such that we can actually build Go
12+
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
13+
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
14+
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
15+
GOOS="$(go env GOOS)" \
16+
GOARCH="$(go env GOARCH)" \
17+
GOHOSTOS="$(go env GOHOSTOS)" \
18+
GOHOSTARCH="$(go env GOHOSTARCH)" \
3019
; \
31-
# also explicitly set GO386 and GOARM if appropriate
32-
# https://github.com/docker-library/golang/issues/184
33-
apkArch="$(apk --print-arch)"; \
34-
case "$apkArch" in \
35-
armhf) export GOARM='6' ;; \
36-
armv7) export GOARM='7' ;; \
37-
x86) export GO386='387' ;; \
20+
# also explicitly set GO386 and GOARM if appropriate
21+
# https://github.com/docker-library/golang/issues/184
22+
dpkgArch="$(dpkg --print-architecture)"; \
23+
case "$dpkgArch" in \
24+
armhf) export GOARM='6' ;; \
25+
armv7) export GOARM='7' ;; \
26+
x86) export GO386='387' ;; \
3827
esac; \
3928
\
4029
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
@@ -45,13 +34,12 @@ RUN set -eux; \
4534
./make.bash; \
4635
\
4736
rm -rf \
48-
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
49-
/usr/local/go/pkg/bootstrap \
50-
# https://golang.org/cl/82095
51-
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
52-
/usr/local/go/pkg/obj \
37+
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
38+
/usr/local/go/pkg/bootstrap \
39+
# https://golang.org/cl/82095
40+
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
41+
/usr/local/go/pkg/obj \
5342
; \
54-
apk del .build-deps; \
5543
\
5644
export PATH="/usr/local/go/bin:$PATH"; \
5745
go version
@@ -61,31 +49,36 @@ ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
6149
ENV GO111MODULE=on
6250

6351
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
64-
RUN apk add -U --no-cache ca-certificates bash nodejs npm python3 python3-dev py-pip ruby jq build-base gnupg git openssh curl gettext libffi libffi-dev openssl-dev php composer php-curl php7-tokenizer wget php-dom php-xml php-simplexml php-xmlwriter maven
52+
RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get install -y nodejs
53+
# the following is a workaround for openjdk-11-jre-headless erroring due to not having a man path in slim-debian
54+
RUN mkdir /usr/share/man/man1/
55+
RUN apt-get install -y --no-install-recommends python3 python3-dev python3-pip ruby jq gnupg git gettext libffi6 libffi-dev libssl-dev php composer php-curl php7.3-tokenizer php-dom php-xml php-simplexml php-xmlwriter maven
6556

6657
# RUN wget http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.2.2/openapi-generator-cli-4.2.2.jar -O openapi-generator-cli.jar
6758

6859
RUN npm i -g @openapitools/openapi-generator-cli
6960
RUN openapi-generator-cli version-manager set 5.0.0
70-
RUN python3 -m pip install --upgrade pip
71-
RUN python3 -m pip install --user --upgrade setuptools wheel twine
61+
RUN pip3 install --upgrade pip
62+
RUN pip3 install --user --upgrade setuptools wheel twine
7263

7364
# dotnet
7465
ENV PATH "$PATH:/root/.dotnet"
7566

76-
RUN apk add --no-cache \
77-
lttng-ust-dev \
78-
icu-libs \
79-
zlib \
80-
&& wget -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \
81-
&& chmod +x dotnet-install.sh \
82-
&& ./dotnet-install.sh --channel Current \
83-
&& rm dotnet-install.sh
67+
RUN apt-get install -y --no-install-recommends \
68+
liblttng-ust-dev \
69+
libicu-dev \
70+
zlib1g \
71+
&& wget -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \
72+
&& chmod +x dotnet-install.sh \
73+
&& ./dotnet-install.sh --channel Current \
74+
&& rm dotnet-install.sh
75+
76+
RUN rm -rf /var/lib/apt/lists/*
8477

8578
RUN download_url=$(curl -s https://api.github.com/repos/go-swagger/go-swagger/releases/latest | \
86-
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url') \
87-
&& curl -o /usr/local/bin/swagger -L'#' "$download_url" \
88-
&& chmod +x /usr/local/bin/swagger
79+
jq -r '.assets[] | select(.name | contains("'"$(uname | tr '[:upper:]' '[:lower:]')"'_amd64")) | .browser_download_url') \
80+
&& curl -o /usr/local/bin/swagger -L'#' "$download_url" \
81+
&& chmod +x /usr/local/bin/swagger
8982

9083
ADD go.mod go.mod
9184
ADD go.sum go.sum

scripts/generate.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typescript () {
3434

3535
dir="clients/${PROJECT}/typescript"
3636

37-
openapi-generator generate -i "${SPEC_FILE}" \
37+
openapi-generator-cli generate -i "${SPEC_FILE}" \
3838
-g typescript-axios \
3939
-o "$dir" \
4040
--git-user-id ory \
@@ -57,7 +57,7 @@ java () {
5757
rm -rf "${dir}/src" || true
5858
rm -rf "${dir}/docs" || true
5959

60-
openapi-generator generate -i "${SPEC_FILE}" \
60+
openapi-generator-cli generate -i "${SPEC_FILE}" \
6161
-g java \
6262
-o "$dir" \
6363
--git-user-id ory \
@@ -117,7 +117,7 @@ php() {
117117

118118
dir="clients/${PROJECT}/php"
119119

120-
openapi-generator generate -i "${SPEC_FILE}" \
120+
openapi-generator-cli generate -i "${SPEC_FILE}" \
121121
-g php \
122122
-o "$dir" \
123123
--git-user-id ory \
@@ -138,7 +138,7 @@ python () {
138138

139139
dir="clients/${PROJECT}/python"
140140

141-
openapi-generator generate -i "${SPEC_FILE}" \
141+
openapi-generator-cli generate -i "${SPEC_FILE}" \
142142
-g python \
143143
-o "$dir" \
144144
--git-user-id ory \
@@ -154,7 +154,7 @@ ruby () {
154154

155155
rm "${dir}/lib/ory-${PROJECT}-client/version.rb" || true
156156

157-
openapi-generator generate -i "${SPEC_FILE}" \
157+
openapi-generator-cli generate -i "${SPEC_FILE}" \
158158
-g ruby \
159159
-o "$dir" \
160160
--git-user-id ory \
@@ -184,7 +184,7 @@ dotnet () {
184184

185185
dir="clients/${PROJECT}/dotnet"
186186

187-
openapi-generator generate -i "${SPEC_FILE}" \
187+
openapi-generator-cli generate -i "${SPEC_FILE}" \
188188
-g csharp-netcore \
189189
-o "$dir" \
190190
--model-name-prefix ${PROJECT_UCF} \

0 commit comments

Comments
 (0)