LoginSignup
0
0

More than 1 year has passed since last update.

Dockerを用いたnode.jsの実行環境構築

Last updated at Posted at 2022-11-28

Dockerを用いてnode.jsの実行環境を構築しました.
nodejsのbase imageをpullせずに,ubuntuのbase imageにnode.jsをインストールする形で構成しました.

#フォルダの構成

├─Dockerfile
└─bash
    └─nodesource_setup.bash

ファイルの内容

Dockerfile
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
    apt-utils sudo git curl vim unzip openssh-client wget gnupg2 lsb-release software-properties-common \
    build-essential cmake \
    libopenblas-dev \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev

# node.jsインストール
WORKDIR /root/
RUN curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
COPY ./bash /root/
RUN ["/bin/bash", "/root/nodesource_setup.bash"]
RUN sudo apt install -y nodejs

RUN sudo apt-get update && \
    sudo apt-get upgrade -y

RUN npm install express
nodesource_setup.bash
sudo bash nodesource_setup.sh

Build

cd /path/to/project_dir
docker build -f ./Dockerfile .

備考

ちなみに,ubuntuのOSに直接aptでインストールする場合は,以下のコマンドで実行できます.

sudo apt-get install -y nodejs npm

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0