-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmake_targets_docker.mk
More file actions
77 lines (65 loc) · 3.11 KB
/
make_targets_docker.mk
File metadata and controls
77 lines (65 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
################################################################################
# Docker Configuration Makefile
#
# This Makefile simplifies the setup and configuration of Docker in a WSL (Windows Subsystem for Linux)
# environment. It commands for system preparation, Docker installation, and post-installation verification.
#
# Targets:
# - `check-wsl`: Verifies and sets WSL to version 2 for Docker compatibility.
# - `docker-full-install`: Executes commands for a complete Docker installation and setup.
# - `docker-remove-old`: Removes prior Docker installations to prevent setup conflicts.
# - `docker-install-dependencies`: Installs required packages for Docker.
# - `docker-add-gpg-key`: Adds Docker's GPG key to ensure package integrity.
# - `docker-add-repo`: Adds Docker's stable repository for package access.
# - `docker-install`: Installs Docker Engine and Docker Compose.
# - `docker-verify`: Confirms Docker's successful installation by running a test container.
#
# Usage:
# Execute `make <target>` to run a specific configuration step. For a full installation, use
# `make` or `make full_install` to perform all setup steps.
################################################################################
# Default target executed when no arguments are given to make.
default:
@echo "Docker Full Install ..."
$(MAKE) docker-full-install
check-wsl:
@echo "Checking WSL version..."
wsl --set-default-version 2
docker-remove-old:
@echo "Removing any old Docker versions..."
sudo apt remove -y docker docker-engine docker.io containerd runc
docker-install-dependencies:
@echo "Updating and installing required packages..."
sudo apt-get update
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
docker-add-gpg-key:
@echo "Adding Docker's official GPG key..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
docker-add-repo:
@echo "Adding Docker's stable repository..."
echo "deb [arch=$$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
docker-build:
@echo "Building Docker..."
@docker build -f .devcontainer/Dockerfile --build-arg USER_ID="$(id -u)" --build-arg GROUP_ID="$(id -g)" -t test-build .
docker-install:
@echo "Installing Docker Engine and Docker Compose..."
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
docker-start:
@echo "Ensuring Docker service is running..."
sudo service docker start
@echo "Docker is running."
devcontainer: docker-start
@echo "Launching Dev Container..."
# Insert the command to launch your dev container here, for example:
# code --folder-uri vscode-remote://dev-container+$(shell wslpath -m .)
docker-verify:
@echo "Verifying Docker installation..."
sudo docker run hello-world
docker-full-install: check-wsl docker-remove-old docker-install-dependencies docker-add-gpg-key docker-add-repo docker-install docker-verify
@echo "Full installation completed successfully."