This section describes how to prepare the system and configure all the necessary components to run the project and CI/CD.
Follow the official instructions:
- Install Docker: https://docs.docker.com/get-docker/
- Install Docker Compose: https://docs.docker.com/compose/install/
Check the installation with the commands:
sudo docker --version
sudo docker compose --versionTo run and develop the project, you will need Docker and Docker Compose. Below are the instructions for popular OS.
# Update packages
sudo apt update
# Install required dependencies
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
# Add official Docker GPG key and repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
# Check Docker version
sudo docker --version
# Install Docker Compose (latest version)
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# Check Docker Compose version
sudo docker compose --version- Windows 10 version 2004 and above or Windows 11 Pro
- Administrator access to the system
- Internet connection
- Open PowerShell as administrator.
- Enter the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart- Then enable virtualization:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart- Restart the computer.
- Open PowerShell as administrator and run:
wsl --versionThe command only works in WSL version 2. If WSL is not installed yet, the command may not work.
For any version of WSL, you can use the command:
wsl --list --verbose- If the command is not recognized, install WSL:
wsl --install- Restart your computer after installation.
After reboot, open PowerShell (as administrator) and run:
wsl --set-default-version 2- Restart your computer and enter BIOS/UEFI (usually Del, F2, F10).
- Find the Virtualization (or VT-x/AMD-V) option.
- Enable it if it is disabled.
Open Microsoft Store.
Find the distribution you need, for example:
- Ubuntu 22.04 LTS
- Debian
- Kali Linux
- openSUSE
Click "Install".
Run in PowerShell:
wsl --install -d Ubuntuπ You can replace Ubuntu with another system, for example:
- Ubuntu-22.04
- Debian
- Kali-Linux
- openSUSE-42
To view available distributions:
wsl --list --onlineβ³ Wait for the installation The process will download and install the selected distribution. After that, the Ubuntu terminal (or another system) will start.
π§ͺ Check Check that everything works:
wsl -l -vYou will see a list of installed distributions and their status.
After installation, open the application (for example, Ubuntu). The first launch will configure the environment.
Enter:
- Username
- Password
This is a local user inside the Linux environment.
After logging in, run:
sudo apt update && sudo apt upgrade -y- macOS 12 or newer (recommended)
- Intel or Apple Silicon chip (M1/M2/M3)
- Administrator access
- Internet connection
- At least 15β20 GB of free space
UTM is a free application for virtualization on macOS, no registration required.
β Steps:
- Go to the website https://mac.getutm.app
- Download UTM and move it to the Applications folder
- Run UTM
Quick installation from a ready-made image:
- In UTM, click Create a New Virtual Machine
- Select Virtualize (if Apple Silicon) or Emulate (if Intel)
- Select Linux
- Download a Linux ISO image (e.g. Ubuntu)
- Follow UTM instructions (name, amount of RAM, disk, etc.)
- Click Save and Start
π‘ For Apple Silicon, choose ARM-compatible images (e.g. Ubuntu Server for ARM64).
If you need CLI access to Ubuntu without a GUI:
Installation:
- Download Multipass: https://multipass.run
- Install via Homebrew:
brew install --cask multipassLaunch Ubuntu:
multipass launch --name ubuntu-ltsConnection:
multipass shell ubuntu-ltsβ‘οΈ Fast, convenient, suitable for developers and server tasks.
If you need a lightweight Linux environment for development, install Docker Desktop:
brew install --cask dockerLaunch and configuration requires a Docker Hub account.
After installing any of the systems, check:
uname -aYou should see the Linux environment inside the virtual machine or container.
For Ubuntu (via terminal):
sudo apt update && sudo apt upgrade -y| Method | Interface | Performance | GUI | Suitable for |
|---|---|---|---|---|
| UTM | Yes | Medium | Yes | Beginners, visuals |
| Multipass | No | High | No | CLI, developers |
| Docker | No | Very high | No | DevOps, microservices |
For secure work with GitHub (cloning repositories, pushing), it is recommended to use SSH keys.
Open the terminal and run:
ls ~/.sshIf you see files like id_rsa and id_rsa.pub or id_ed25519 and id_ed25519.pub, the key already exists.
If not, create one π
ssh-keygen -t ed25519 -C "your_email@example.com"If prompted, specify the path (default is ~/.ssh/id_ed25519)
You can add a password for the key (recommended)
If ed25519 is not supported (on old OpenSSH), use rsa:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"Run:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519Copy the contents of the public key:
cat ~/.ssh/id_ed25519.pubGo to GitHub:
Settings β SSH and GPG keys β New SSH key
Paste the key and save.
Run:
ssh -T git@github.comWhen connecting for the first time, confirm trust
You should see a message greeting GitHub (Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access)
If you cloned via HTTPS, replace the URL:
git remote set-url origin git@github.com:USERNAME/<project_name>.gitCheck:
git remote -vIt should now be:
origin git@github.com:Hackitect7/devops-docker-project.git (fetch)
origin git@github.com:Hackitect7/devops-docker-project.git (push)
Now push/pull/clone will work without logins and tokens.
To automatically publish images to Docker Hub via GitHub Actions, you need an Access Token.
- Log in to Docker Hub: https://hub.docker.com/
- Go to Account:
Settings β Security β New Access Token
- Name the token (e.g. "GitHub Actions Token") and create it.
- Copy the token - it will not be displayed anymore.
- The token is used instead of a password when logging in to Docker Hub from CI/CD.
- Allows you to securely publish images from an automated pipeline.
- Protects your account by allowing you to revoke access at any time.
In order for GitHub Actions to be able to log into Docker Hub and pull images, you need to add secrets to the repository.
Open the repository on GitHub.
Go to:
Settings β Secrets and variables β Actions β New repository secret
Create the following secrets:
DOCKER_USERNAMEβ your Docker Hub loginDOCKER_PASSWORDβ your Docker Hub Access Token (not your password!)
.github/workflows/docker-ci.yml uses these secrets for authentication and push.
The project structure is organized in such a way that it is convenient to develop and maintain:
/backend/ # Backend application on Python Flask
βββ app.py # Main Flask API code
βββ requirements.txt # Python dependencies
βββ Dockerfile # Instructions for building the Docker image backend
/frontend/ # Frontend application on Node.js (Express)
βββ index.js # Main code of the frontend server
βββ package.json # Dependencies and Node.js scripts
βββ package.jsonc # Dependencies and Node.js scripts with comments (not used)
βββ package-lock.json # Automatically generated lock-file
βββ Dockerfile # Frontend Docker image build instructions
/nginx/ # Nginx configuration
βββ nginx.conf # Reverse proxy config
βββ Dockerfile # Nginx Docker image build instructions
.github/workflows/ # CI/CD configuration GitHub Actions
βββ docker-ci.yml # Script for building, testing and pushing images
docker-compose.yml # Defining services for local development via Docker Compose
docker-compose.prod.yml # Defining services for installing them into production from Docker Hub
.dockerignore # List of files and folders excluded from the Docker build context (e.g. node_modules, .git)
.env # File with environment variables (does not get into Git, used Docker Compose and scripts)
.gitignore # Defines which files and folders should not be included in the Git repository (e.g. .env, __pycache__)
LICENSE # Project license text (e.g. MIT, Apache 2.0) β defines the rules for using the code
CONTRIBUTING.md # Guidelines and rules for external participants wishing to contribute to the project (pull requests, style guide)