-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnightscout-ec-docker.yaml
117 lines (112 loc) · 4.23 KB
/
nightscout-ec-docker.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
AMI:
Type: String
Description: The ID of the Amazon Machine Image (AMI) to use for the EC2 instance
Default: ami-08fc6fb8ad2e794bb # Default AMI ID for Amazon Linux 2023 (HVM), SSD Volume Type (64-bit arm)
InstanceType:
Type: String
Description: The instance type for the EC2 instance
Default: t4g.small
APISecret:
Type: String
Description: The API secret for Nightscout container
Default:
Enable:
Type: String
Description: List of Nightscout features to enable
Default: careportal basal iob cob bridge
BridgeUsername:
Type: String
Description: The username for the Nightscout bridge
Default:
BridgePassword:
Type: String
Description: The password for the Nightscout bridge
Default:
BridgeServer:
Type: String
Description: The server for the Nightscout bridge
Default: EU
MongoConnection:
Type: String
Description: The connection string for MongoDb
Default:
KeyPair:
Type: String
Description: The key pair for the EC2 instance
Default:
Resources:
MyElasticIP:
Type: AWS::EC2::EIP
NightscoutInstance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !Ref AMI
InstanceType: !Ref InstanceType
KeyName: !Ref KeyPair
UserData:
Fn::Base64: !Sub |
#!/bin/bash
cat << 'EOF' > /home/ec2-user/docker-compose.yml
version: '3'
services:
nightscout:
image: nightscout/cgm-remote-monitor:latest
container_name: nightscout
environment:
- API_SECRET=${APISecret}
- INSECURE_USE_HTTP=true
- NODE_ENV=production
- TZ=Etc/UTC
- ENABLE=${Enable}
- BRIDGE_USER_NAME=${BridgeUsername}
- BRIDGE_PASSWORD=${BridgePassword}
- MONGO_CONNECTION=${MongoConnection}
- BRIDGE_SERVER=${BridgeServer}
- AUTH_DEFAULT_ROLES=denied
- DISPLAY_UNITS=mmol/L
labels:
- "traefik.enable=true"
- "traefik.http.routers.nightscout.rule=Host(`${MyElasticIP.PublicIp}`)"
- 'traefik.http.routers.nightscout.entrypoints=websecure'
- 'traefik.http.routers.nightscout.tls.certresolver=le'
traefik:
image: traefik:latest
container_name: traefik
volumes:
- './letsencrypt:/letsencrypt'
- /var/run/docker.sock:/var/run/docker.sock:ro
command:
- '--providers.docker=true'
- '--providers.docker.exposedbydefault=false'
- '--entrypoints.web.address=:80'
- '--entrypoints.web.http.redirections.entrypoint.to=websecure'
- '--entrypoints.websecure.address=:443'
- "--certificatesresolvers.le.acme.httpchallenge=true"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
- '--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json'
ports:
- "80:80"
- "443:443"
EOF
sudo yum update -y
sudo yum install docker -y
#sudo usermod -a -G docker ec2-user
#sudo chkconfig docker on
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
systemctl enable docker
systemctl start docker
docker-compose -f /home/ec2-user/docker-compose.yml up -d
DependsOn: MyElasticIP
ElasticIpAssociation:
Type: AWS::EC2::EIPAssociation
Properties:
InstanceId: !Ref NightscoutInstance
AllocationId: !GetAtt MyElasticIP.AllocationId
Outputs:
NightscoutInstanceIP:
Value: !GetAtt NightscoutInstance.PublicIp
Description: Public IP address of the Nightscout instance