Welcome to FreeSoftwareServers Confluence Wiki

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

services:
 odev:
    container_name: odev
    image: nginx
    hostname: odev
    ports:
      - '8080:80'

    volumes:
      - type: bind
        source: /opt/odev/html/
        target: /usr/share/nginx/html
      - type: bind
        source: /opt/odev/mnt/
        target: /mnt

    environment:
      - 'TZ=${TZ}'

EOF
chmod +x docker-compose.yaml
cat <<'EOF'>$WD/html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
EOF
cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
EOF
chmod +x .env
WD=/opt/odev/setup
cat << EOF >$WD/odev.service.setup.sh
cat << EOL >/lib/systemd/system/odev.service
[Unit]
Description=odev_Docker
Requires=docker.service network-online.target

[Service]  

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

[Install]
WantedBy=multi-user.target
EOL
systemctl enable odev
systemctl restart odev
systemctl status odev
EOF
chmod +x $WD/odev.service.setup.sh
$WD/odev.service.setup.sh
echo 'alias odevcli="docker exec -it odev /bin/bash"' >> ~/.bashrc
source ~/.bashrc
  • No labels