Welcome to FreeSoftwareServers Confluence Wiki

WD=/opt/krakend
mkdir -p $WD/{setup,conf}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 krakend:
    container_name: krakend
    image: devopsfaith/krakend
    hostname: krakend
    ports:
      - '8525:8080'
    volumes:
      - type: bind
        source: /opt/krakend/conf/
        target: /etc/krakend

    environment:
      - 'TZ=${TZ}'

EOF
chmod +x docker-compose.yaml
cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
EOF
chmod +x .env
WD=/opt/krakend/setup
cat << EOF >$WD/krakend.service.setup.sh
cat << EOL >/lib/systemd/system/krakend.service
[Unit]
Description=krakend_Docker
Requires=docker.service network-online.target

[Service]  

WorkingDirectory=$WD
ExecStartPre=docker-compose pull
Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name krakend --project-directory $WD -f $WD/docker-compose.yaml up --force-recreate
ExecStop=/usr/bin/docker-compose --project-name krakend --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable krakend
systemctl restart krakend
systemctl status krakend
EOF
chmod +x $WD/krakend.service.setup.sh
$WD/krakend.service.setup.sh
  • No labels