2019-11-05 09:43:08 +00:00
|
|
|
CLEAN_PACKAGES=\
|
|
|
|
docker \
|
|
|
|
docker-engine \
|
|
|
|
docker.io \
|
|
|
|
containerd \
|
|
|
|
runc
|
|
|
|
|
|
|
|
REQUIRED_PACKAGES=\
|
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
|
|
|
curl \
|
|
|
|
gnupg-agent \
|
|
|
|
software-properties-common
|
|
|
|
|
|
|
|
DOCKER_PACKAGES=\
|
|
|
|
docker-ce \
|
|
|
|
docker-ce-cli \
|
|
|
|
containerd.io
|
|
|
|
|
2019-11-05 16:10:38 +00:00
|
|
|
HOME_BIN_DIR=$(HOME)/bin
|
|
|
|
|
|
|
|
DOCKER_BIN=/usr/bin/docker
|
|
|
|
DOCKER_COMPOSE_BIN=$(HOME_BIN_DIR)/docker-compose
|
|
|
|
DOCKER_REPO_FILE=/etc/apt/sources.list.d/docker.list
|
2019-11-26 09:35:19 +00:00
|
|
|
DOCKER_COMPOSE_VERSION=1.25.0
|
|
|
|
DOCKER_COMPOSE_URL=https://github.com/docker/compose/releases/download/$(DOCKER_COMPOSE_VERSION)/docker-compose-$(shell uname -s)-$(shell uname -m)
|
2019-11-05 16:10:38 +00:00
|
|
|
|
|
|
|
ROOT_TEE=sudo tee
|
2019-11-05 09:43:08 +00:00
|
|
|
ROOT_APT=sudo aptitude
|
|
|
|
ROOT_ADD_KEY=sudo apt-key
|
2019-11-05 16:10:38 +00:00
|
|
|
ROOT_ADD_USER_TO_GROUP=sudo adduser
|
2019-11-05 09:43:08 +00:00
|
|
|
RELEASE:=$(shell lsb_release -cs)
|
|
|
|
|
2019-11-26 09:35:19 +00:00
|
|
|
clean: clean_docker clean_compose
|
|
|
|
|
|
|
|
clean_docker:
|
2019-11-05 16:10:38 +00:00
|
|
|
-docker system prune
|
|
|
|
-$(ROOT_APT) remove $(DOCKER_PACKAGES)
|
|
|
|
sudo rm -f $(DOCKER_REPO_FILE)
|
|
|
|
-$(ROOT_ADD_KEY) del Docker
|
|
|
|
|
2019-11-26 09:35:19 +00:00
|
|
|
clean_compose:
|
|
|
|
rm -f $(DOCKER_COMPOSE_BIN)
|
|
|
|
|
2019-11-05 16:10:38 +00:00
|
|
|
install: install_docker install_compose
|
|
|
|
install_docker: $(DOCKER_BIN)
|
2019-11-26 09:35:19 +00:00
|
|
|
|
|
|
|
install_compose:
|
|
|
|
ifeq ("$(wildcard $(DOCKER_COMPOSE_BIN))","")
|
|
|
|
$(MAKE) download_install_compose
|
|
|
|
else ifneq ($(shell docker-compose -v | awk -F'[, ]' '{print $$3}'), $(DOCKER_COMPOSE_VERSION))
|
|
|
|
$(MAKE) download_install_compose
|
|
|
|
endif
|
|
|
|
|
|
|
|
force_update_compose: clean_compose install_compose
|
2019-11-05 09:43:08 +00:00
|
|
|
|
2019-11-05 16:10:38 +00:00
|
|
|
$(DOCKER_BIN):
|
|
|
|
-$(ROOT_APT) remove $(CLEAN_PACKAGES)
|
2019-11-05 09:43:08 +00:00
|
|
|
$(ROOT_APT) update
|
|
|
|
$(ROOT_APT) install -y $(REQUIRED_PACKAGES)
|
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | $(ROOT_ADD_KEY) add -
|
2019-11-05 16:10:38 +00:00
|
|
|
echo "deb https://download.docker.com/linux/ubuntu $(RELEASE) stable" \
|
|
|
|
| $(ROOT_TEE) $(DOCKER_REPO_FILE)
|
2019-11-05 09:43:08 +00:00
|
|
|
$(ROOT_APT) update
|
|
|
|
$(ROOT_APT) install -y $(DOCKER_PACKAGES)
|
|
|
|
$(ROOT_ADD_USER_TO_GROUP) $(shell id -nu) docker
|
2019-11-05 16:10:38 +00:00
|
|
|
|
|
|
|
|
2019-11-26 09:35:19 +00:00
|
|
|
download_install_compose: $(HOME_BIN_DIR)
|
|
|
|
curl -L $(DOCKER_COMPOSE_URL) -o $(DOCKER_COMPOSE_BIN)
|
2019-11-05 16:10:38 +00:00
|
|
|
chmod +x $(DOCKER_COMPOSE_BIN)
|
|
|
|
|
|
|
|
$(HOME_BIN_DIR):
|
|
|
|
mkdir -p $(HOME_BIN_DIR)
|