-
Notifications
You must be signed in to change notification settings - Fork 0
/
lightsail-compose.sh
54 lines (41 loc) · 1.39 KB
/
lightsail-compose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# install latest version of docker the lazy way
curl -sSL https://get.docker.com | sh
# make it so you don't need to sudo to run docker commands
usermod -aG docker ubuntu
# install docker-compose
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# copy the dockerfile into /srv/docker
# if you change this, change the systemd service file to match
# WorkingDirectory=[whatever you have below]
mkdir /srv/docker
echo "
version: \"3.2\"
services:
site:
image: skela/davincium:latest
ports:
- \"80:80\"
" > /srv/docker/docker-compose.yml
# copy in systemd unit file and register it so our compose file runs
# on system restart
echo "
# /etc/systemd/system/docker-compose-app.service
# thanks to oleg belostotsky on stack overflow for this
[Unit]
Description=Docker Compose Application Service
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
# match the below to wherever you copied your docker-compose.yml
WorkingDirectory=/srv/docker
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
" > /etc/systemd/system/docker-compose-app.service
systemctl enable docker-compose-app