Created
January 31, 2024 01:03
-
-
Save wxk6b1203/0371c5235b1043f7320dcbeea24647c2 to your computer and use it in GitHub Desktop.
Dockerfile builds Node.js with ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
LABEL maintainer="wxk6b1203 <xxx>" | |
# Default to UTF-8 file.encoding | |
ENV LANG en_US.UTF-8 | |
RUN groupadd --gid 1000 node \ | |
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node | |
ENV NODE_VERSION 20.11.0 | |
ENV ARCH x64 | |
# change to your favourate mirror | |
RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list \ | |
&& apt-get update \ | |
&& apt-get install -y git iputils-ping curl openssl xz-utils \ | |
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \ | |
&& ls -al \ | |
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ | |
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \ | |
&& apt-get remove -y xz-utils \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& node --version \ | |
&& npm --version | |
ENV YARN_VERSION 1.22.19 | |
RUN curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \ | |
&& mkdir -p /opt \ | |
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ | |
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ | |
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ | |
&& rm yarn-v$YARN_VERSION.tar.gz \ | |
# smoke test | |
&& yarn --version | |
# COPY docker-entrypoint.sh /usr/local/bin/ | |
# ENTRYPOINT ["docker-entrypoint.sh"] | |
CMD [ "node" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment