Browse Source

Fix non-x64 architectures not being able to build Docker image because of hardcoded Node.js architecture (#13081)

* Use ARCH variable instead of hardcoded x64

* fix formating
Sara Aimée Smiseth 4 months ago
parent
commit
250ca99cb5
No account linked to committer's email address
1 changed files with 16 additions and 5 deletions
  1. 16
    5
      Dockerfile

+ 16
- 5
Dockerfile View File

@@ -5,14 +5,25 @@ SHELL ["bash", "-c"]
5 5
 
6 6
 # Install Node v12 (LTS)
7 7
 ENV NODE_VER="12.14.0"  
8
-RUN	echo "Etc/UTC" > /etc/localtime && \
8
+RUN	ARCH= && \
9
+    dpkgArch="$(dpkg --print-architecture)" && \
10
+  case "${dpkgArch##*-}" in \
11
+    amd64) ARCH='x64';; \
12
+    ppc64el) ARCH='ppc64le';; \
13
+    s390x) ARCH='s390x';; \
14
+    arm64) ARCH='arm64';; \
15
+    armhf) ARCH='armv7l';; \
16
+    i386) ARCH='x86';; \
17
+    *) echo "unsupported architecture"; exit 1 ;; \
18
+  esac && \
19
+    echo "Etc/UTC" > /etc/localtime && \
9 20
 	apt update && \
10 21
 	apt -y install wget python && \
11 22
 	cd ~ && \
12
-	wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER-linux-x64.tar.gz && \
13
-	tar xf node-v$NODE_VER-linux-x64.tar.gz && \
14
-	rm node-v$NODE_VER-linux-x64.tar.gz && \
15
-	mv node-v$NODE_VER-linux-x64 /opt/node
23
+	wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER-linux-$ARCH.tar.gz && \
24
+	tar xf node-v$NODE_VER-linux-$ARCH.tar.gz && \
25
+	rm node-v$NODE_VER-linux-$ARCH.tar.gz && \
26
+	mv node-v$NODE_VER-linux-$ARCH /opt/node
16 27
 
17 28
 # Install jemalloc
18 29
 ENV JE_VER="5.2.1"

Loading…
Cancel
Save