Last active
September 16, 2020 23:54
-
-
Save glenselle/19b5fb642514a55b160562f73d8b7887 to your computer and use it in GitHub Desktop.
Simple CentOS Docker HA Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo Updating the CentOS installation... | |
yum -y update && yum -y upgrade | |
echo Adding firewall rules for ssh/http/https... | |
systemctl enable firewalld | |
systemctl start firewalld | |
firewall-cmd --add-service=ssh --permanent | |
firewall-cmd --add-service=http --permanent | |
firewall-cmd --add-service=https --permanent | |
firewall-cmd --reload | |
firewall-cmd --state | |
echo Disabling Ctr+Alt+Delete Reboots... | |
systemctl mask ctrl-alt-del.target | |
echo Installing Docker... | |
sudo yum -y remove docker \ | |
docker-client \ | |
docker-client-latest \ | |
docker-common \ | |
docker-latest \ | |
docker-latest-logrotate \ | |
docker-logrotate \ | |
docker-engine | |
sudo yum -y install -y yum-utils | |
sudo yum-config-manager \ | |
--add-repo \ | |
https://download.docker.com/linux/centos/docker-ce.repo | |
sudo yum -y install docker-ce docker-ce-cli containerd.io | |
echo Creating infrastructure Docker compose file... | |
cat << 'EOF' >> docker-compose.yml | |
version: '3' | |
services: | |
strapi: | |
image: strapi/strapi | |
environment: | |
DATABASE_CLIENT: postgres | |
DATABASE_NAME: strapi | |
DATABASE_HOST: postgres | |
DATABASE_PORT: 5432 | |
DATABASE_USERNAME: strapi | |
DATABASE_PASSWORD: strapi | |
links: | |
- postgres:postgres | |
volumes: | |
- ./app:/srv/app | |
ports: | |
- '1337:1337' | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.strapi.rule=Host(`strapi.localhost`)" | |
- "traefik.http.routers.strapi.entrypoints=web" | |
postgres: | |
image: postgres | |
environment: | |
POSTGRES_USER: strapi | |
POSTGRES_PASSWORD: strapi | |
volumes: | |
- ./data:/data/postgres | |
ports: | |
- '5432:5432' | |
traefik: | |
image: "traefik:v2.2" | |
container_name: "traefik" | |
command: | |
#- "--log.level=DEBUG" | |
- "--api.insecure=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.web.address=:80" | |
ports: | |
- "80:80" | |
- "8080:8080" | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" | |
registry: | |
restart: always | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
environment: | |
REGISTRY_HTTP_TLS_CERTIFICATE: /certs/domain.crt | |
REGISTRY_HTTP_TLS_KEY: /certs/domain.key | |
REGISTRY_AUTH: htpasswd | |
REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd | |
REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm | |
volumes: | |
- /path/data:/var/lib/registry | |
- /path/certs:/certs | |
- /path/auth:/auth | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment