Skip to content

Commit

Permalink
docker: run clean apt-get to reduce size of docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
mickamy committed Jan 7, 2024
1 parent bb2c4ba commit 1e36ad2
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docker/app/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ RUN apt-get update && \
apt-get install -y wget sudo less vim tzdata \
nginx \
# 各言語のインストールに必要なもの下準備 \
curl git gcc make libssl-dev libreadline-dev
curl git gcc make libssl-dev libreadline-dev && \
apt-get clean

# ishocon ユーザ作成
RUN groupadd -g 1001 ishocon && \
Expand Down
3 changes: 2 additions & 1 deletion docker/app/crystal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ RUN curl -fsSL https://packagecloud.io/84codes/crystal/gpgkey | gpg --dearmor |
. /etc/os-release && \
echo "deb https://packagecloud.io/84codes/crystal/$ID $VERSION_CODENAME main" | sudo tee /etc/apt/sources.list.d/84codes_crystal.list && \
sudo apt-get update && \
sudo apt-get install -y crystal
sudo apt-get install -y crystal && \
apt-get clean

# アプリケーション
COPY --chown=ishocon:ishocon webapp/ /home/ishocon/webapp
Expand Down
2 changes: 0 additions & 2 deletions docker/app/go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ FROM ${BASE_IMAGE}
ARG TARGETARCH
ENV GOARCH ${TARGETARCH}

RUN sudo apt-get update

# Go のインストール
ARG TARGETARCH
RUN sudo wget -q https://dl.google.com/go/go1.15.8.linux-${TARGETARCH}.tar.gz && \
Expand Down
5 changes: 3 additions & 2 deletions docker/app/nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM ${BASE_IMAGE}

# NodeJS のインストール
RUN sudo apt-get update
RUN sudo apt install -y nodejs-dev node-gyp libssl1.0-dev
RUN sudo apt install -y nodejs npm
RUN sudo apt install -y nodejs-dev node-gyp libssl1.0-dev \
nodejs npm && \
apt-get clean

# アプリケーション
COPY --chown=ishocon:ishocon webapp/ /home/ishocon/webapp
Expand Down
5 changes: 3 additions & 2 deletions docker/app/php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM ${BASE_IMAGE}

# PHP のインストール
RUN sudo mkdir /run/php
RUN sudo apt-get update
RUN sudo apt install -y php php-fpm php-mysql php-cli
RUN sudo apt-get update && \
sudo apt install -y php php-fpm php-mysql php-cli && \
apt-get clean

# アプリケーション
COPY --chown=ishocon:ishocon webapp/ /home/ishocon/webapp
Expand Down
5 changes: 3 additions & 2 deletions docker/app/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ ARG BASE_IMAGE=showwin/ishocon2_app_base:latest
FROM ${BASE_IMAGE}

# Python のインストール
RUN sudo apt-get update
RUN sudo apt-get install -y zlib1g-dev
RUN sudo apt-get update && \
sudo apt-get install -y zlib1g-dev && \
apt-get clean
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \
PYENV_ROOT="$HOME/.pyenv" && PATH="$PYENV_ROOT/bin:$PATH" && \
eval "$(pyenv init -)" && \
Expand Down
1 change: 1 addition & 0 deletions docker/app/ruby/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ${BASE_IMAGE}
# Ruby のインストール
RUN sudo apt-get update && \
sudo apt-get install -y ruby-dev libmysqlclient-dev libffi6 libffi-dev libyaml-dev bzip2 && \
apt-get clean && \
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
RUN PATH="$HOME/.rbenv/bin:$PATH" && \
eval "$(rbenv init -)" && \
Expand Down
12 changes: 7 additions & 5 deletions docker/benchmarker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ ENV LC_ALL=C.UTF-8
ENV TZ Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# MySQL のインストール
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-server mysql-server/root_password password ishocon'"]
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-service mysql-server/mysql-apt-config string 4'"]

RUN apt-get update && \
apt-get install -y wget mysql-server git tzdata
apt-get install -y wget tzdata

# Go のインストール
ARG TARGETARCH
Expand All @@ -33,6 +29,12 @@ COPY admin/config/my.bench.cnf /etc/mysql/my.cnf

WORKDIR /root

# MySQL のインストール
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-server mysql-server/root_password password ishocon'"]
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mysql-service mysql-server/mysql-apt-config string 4'"]
RUN apt-get install -y mysql-server && \
apt-get clean

# 初期データ投入
RUN service mysql start && \
mysql -u root -pishocon -e 'CREATE DATABASE IF NOT EXISTS ishocon2;' && \
Expand Down

0 comments on commit 1e36ad2

Please sign in to comment.