This tutorial will guide you through the process of setting up Podman Compose on a Debian instance, including steps to ensure the virtual environment is activated every time you SSH into your server. Additionally, it will cover generating an SSH key to pull code from GitHub, creating a directory in /etc/
to store the app codebase, installing NVM for Node.js, and resolving common issues related to Podman.
- Automated Setup Script
- Step 1: Update and Install Necessary Packages
- Step 2: Create and Activate the Virtual Environment
- Step 3: Install Podman Compose
- Step 4: Verify the Installation
- Step 5: Automatically Activate the Virtual Environment on SSH
- Step 6: Generate an SSH Key
- Step 7: Create a Directory in
/etc/
for the Project - Step 8: Pull Code from GitHub
- Step 9: Install NVM (Node Version Manager) and Node.js
- Step 10: Configure Default Registries for Podman
- Step 11: Install Hasura CLI Using the Official Script
- Step 12: Resolve Common Issues
- Summary
To automate the setup process, you can use the following script. This script accepts parameters for your email address and project name.
./scripts/setup_podman_compose.sh -e [email protected] -p your_project_name
Update the package list and install Podman, Python pip, the virtual environment package, and Git:
sudo apt update
sudo apt install podman python3-pip python3-venv git -y
Create a virtual environment for Podman Compose:
python3 -m venv ~/podman_env
Activate the virtual environment:
source ~/podman_env/bin/activate
Within the activated virtual environment, install Podman Compose:
pip install podman-compose
Ensure Podman Compose is installed correctly by checking its version:
podman-compose --version
To ensure the virtual environment is activated every time you SSH into your Debian server, add the activation command to your shell's startup script.
-
Open the
~/.bashrc
file in a text editor:nano ~/.bashrc
-
Add the following line to the end of the file:
source ~/podman_env/bin/activate
-
Save and close the file. In
nano
, you can save by pressingCTRL + O
, then pressENTER
to confirm. Close the editor by pressingCTRL + X
. -
Reload the startup script to apply the changes:
source ~/.bashrc
- Open the `
~/.zshrc` file in a text editor:
nano ~/.zshrc
-
Add the following line to the end of the file:
source ~/podman_env/bin/activate
-
Save and close the file. In
nano
, you can save by pressingCTRL + O
, then pressENTER
to confirm. Close the editor by pressingCTRL + X
. -
Reload the startup script to apply the changes:
source ~/.zshrc
To securely pull code from GitHub, generate an SSH key and add it to your GitHub account.
-
Generate a new SSH key pair:
ssh-keygen -t ed25519 -C "[email protected]"
If you are using an older system that does not support the
ed25519
algorithm, you can usersa
:ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
When prompted to "Enter a file in which to save the key," press
ENTER
to accept the default file location. -
When prompted, enter a secure passphrase (optional).
-
Add your SSH key to the SSH agent:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
For RSA, the command would be:
ssh-add ~/.ssh/id_rsa
-
Copy the SSH key to your clipboard:
cat ~/.ssh/id_ed25519.pub
For RSA, the command would be:
cat ~/.ssh/id_rsa.pub
-
Log in to your GitHub account, navigate to Settings > SSH and GPG keys, and click New SSH key. Paste your SSH key into the "Key" field and give it a descriptive title.
-
Create the directory in
/etc/
:sudo mkdir /etc/your_project_name
-
Change the ownership of the directory to your user:
sudo chown $USER:$USER /etc/your_project_name
-
Navigate to the newly created directory:
cd /etc/your_project_name
-
Clone your repository using SSH:
git clone [email protected]:your_username/your_repository.git
-
Download and install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
-
Load NVM into the current shell session:
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
-
Install the latest LTS version of Node.js:
nvm install --lts
-
Verify the installation:
node -v npm -v
-
Open the
/etc/containers/registries.conf
file in a text editor:sudo vim /etc/containers/registries.conf
-
Add the following configuration under the
[registries.search]
section:[registries.search] registries = ['docker.io', 'quay.io', 'registry.fedoraproject.org']
-
Save and close the file. In
vim
, you can save and exit by pressingESC
to enter command mode, then type:wq
and pressENTER
.
-
Download and install the Hasura CLI:
curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
-
Verify the installation:
hasura version
If you encounter the error failed to move the rootless netns slirp4netns process to the systemd user.slice
, it indicates that dbus-launch
is not found in your $PATH
. Install the dbus
package to resolve this:
sudo apt install dbus -y
By default, rootless Podman cannot bind to ports below 1024. You can allow rootless users to bind to ports 80 and 443 by modifying net.ipv4.ip_unprivileged_port_start
:
-
Edit the
/etc/sysctl.conf
file:sudo vim /etc/sysctl.conf
-
Add the following line to the file:
net.ipv4.ip_unprivileged_port_start=80
-
Save and close the file. Then, apply the change:
sudo sysctl -p
-
Install necessary dependencies:
sudo apt install slirp4netns -y
-
Enable linger for your user:
sudo loginctl enable-linger $USER
-
Enable and start the
podman
service for your user:systemctl --user enable podman systemctl --user start podman
-
Restart your system to ensure all changes take effect.
You have now set up Podman Compose on your Debian system, configured your environment to automatically activate the Podman virtual environment every time you SSH into your server, generated an SSH key, added it to your GitHub account, created a directory in /etc/
to store the app codebase, pulled code from GitHub, installed NVM along with the latest LTS version of Node.js, and resolved common issues related to Podman.
With these steps, you're all set to run your multi-container applications seamlessly. Happy coding, and may your servers be ever stable!