Skip to content

Instantly share code, notes, and snippets.

@nakamorichi
Last active August 14, 2017 01:09
Show Gist options
  • Save nakamorichi/9a7b564a26545eaa249485ccce1268f6 to your computer and use it in GitHub Desktop.
Save nakamorichi/9a7b564a26545eaa249485ccce1268f6 to your computer and use it in GitHub Desktop.
Dockerイメージの作り方 ref: http://qiita.com/Kitanotori/items/c1cfe19fcd29f7b0746c
# FROM <イメージ名>:<バージョンタグ>
# このイメージを元に使って
FROM node:8.2.1-alpine
# イメージの中にアプリ用ディレクトリを作成
RUN mkdir -p /opt/myapp
# イメージの中の"cd"
WORKDIR /opt/myapp
# Dockerfileのディレクトリの中身をイメージの中のWORKDIRにコピー
COPY . .
# コンパイルステップは一つのRUNだけで行う
RUN \
# コンパイルに必要な依存をインストール
apk add --no-cache --virtual build-deps \
python=2.7.13-r1 \
make=4.2.1-r0 \
g++=6.3.0-r4 && \
# コンパイル
npm rebuild && \
# コンパイル依存はもういらないのでイメージに無駄に入らないように同じRUNの中でアンインストール
apk del build-deps
# コンテナのポート8000をホストに開示
EXPOSE 8000
# イメージの起動の時実行されるコマンド
CMD ["npx", "http-server", "-p", "8000"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment