From 719ba8ba6c060668664d6a62d7cd46c4e3b327f0 Mon Sep 17 00:00:00 2001 From: Alexander Stehlik Date: Mon, 29 Aug 2022 13:58:53 +0200 Subject: [PATCH] [TASK] Update to Ubuntu 22.04, install compose plugin Also: move install steps to shell script to reduce image size and number of layers. --- Dockerfile | 29 +++++++---------------------- install_docker.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 install_docker.sh diff --git a/Dockerfile b/Dockerfile index 1eaaed7..9ed801d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,12 @@ -FROM ubuntu:18.04 +FROM ubuntu:22.04 -RUN apt-get update \ - && apt-get dist-upgrade -y +ENV DEBIAN_FRONTEND noninteractive +ENV LANG C.UTF-8 -RUN apt-get install -y apt-transport-https ca-certificates curl software-properties-common +COPY install_docker.sh /opt/install_docker.sh -RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - +RUN bash /opt/install_docker.sh -RUN add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" - -RUN apt-get update \ - && apt-get install -y docker-ce - - -RUN COMPOSE_VERSION=`curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'` \ - && sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose" \ +RUN COMPOSE_VERSION="$(curl --silent "https://api.github.com/repos/docker/compose/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" \ + && sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose" \ && chmod +x /usr/local/bin/docker-compose - -RUN apt-get purge -y apt-transport-https software-properties-common \ - && apt-get --purge -y autoremove \ - && apt-get autoclean \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* diff --git a/install_docker.sh b/install_docker.sh new file mode 100644 index 0000000..d169457 --- /dev/null +++ b/install_docker.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +apt-get update + +apt-get dist-upgrade -y + +apt-get install -y apt-transport-https ca-certificates curl software-properties-common + +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + +add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" + +apt-get update + +apt-get install -y docker-ce docker-compose-plugin + +apt-get purge -y apt-transport-https software-properties-common +apt-get --purge -y autoremove +apt-get autoclean +apt-get clean +rm -rf /var/lib/apt/lists/*