How_To_Linux_Solutions/day_4/nginx.sh

29 lines
726 B
Bash
Raw Normal View History

2022-08-29 20:35:42 +00:00
#!/usr/bin/env bash
# In this solution, 0 is used instead of N
# Check if required directory exists
if [ ! -d ~/nginx0 ]
then
echo "~/nginx0 missing!"
exit 1
fi
# Create container
podman create \
--name nginx0 \
--network traefik \
-v ~/nginx0/website:/volumes/website:Z,ro \
-v ~/nginx0/conf:/etc/nginx/conf.d:Z,ro \
--tz local \
--label "io.containers.autoupdate=registry" \
docker.io/library/nginx:alpine
# Change current directory to not have to move the systemd service file afterwards
cd ~/.config/systemd/user
# Generate the systemd service file
podman generate systemd --new --files --name nginx0
# Enable and start the container
systemctl --user enable --now container-nginx0