mirror of
https://gitlab.com/ser-cal/m346.git
synced 2024-11-27 02:11:56 +01:00
74 lines
3.0 KiB
YAML
74 lines
3.0 KiB
YAML
|
#cloud-config
|
||
|
users:
|
||
|
- name: ubuntu
|
||
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
||
|
groups: users, admin
|
||
|
home: /home/ubuntu
|
||
|
shell: /bin/bash
|
||
|
ssh_authorized_keys:
|
||
|
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0WGP1EZykEtv5YGC9nMiPFW3U3DmZNzKFO5nEu6uozEHh4jLZzPNHSrfFTuQ2GnRDSt+XbOtTLdcj26+iPNiFoFha42aCIzYjt6V8Z+SQ9pzF4jPPzxwXfDdkEWylgoNnZ+4MG1lNFqa8aO7F62tX0Yj5khjC0Bs7Mb2cHLx1XZaxJV6qSaulDuBbLYe8QUZXkMc7wmob3PM0kflfolR3LE7LResIHWa4j4FL6r5cQmFlDU2BDPpKMFMGUfRSFiUtaWBNXFOWHQBC2+uKmuMPYP4vJC9sBgqMvPN/X2KyemqdMvdKXnCfrzadHuSSJYEzD64Cve5Zl9yVvY4AqyBD aws-key
|
||
|
ssh_pwauth: true
|
||
|
disable_root: false
|
||
|
package_update: true
|
||
|
packages:
|
||
|
- curl
|
||
|
- wget
|
||
|
- nginx
|
||
|
- aspnetcore-runtime-6.0
|
||
|
write_files:
|
||
|
- content: |
|
||
|
[Unit]
|
||
|
Description=Demo Shop
|
||
|
[Service]
|
||
|
WorkingDirectory=/var/www/app
|
||
|
ExecStart=/usr/bin/dotnet /var/www/app/ShopDemo.dll
|
||
|
Restart=always
|
||
|
RestartSec=10
|
||
|
KillSignal=SIGINT
|
||
|
SyslogIdentifier=dotnet-example
|
||
|
User=www-data
|
||
|
Environment=ASPNETCORE_ENVIRONMENT=Production
|
||
|
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
||
|
[Install]
|
||
|
WantedBy=multi-user.target
|
||
|
path: /etc/systemd/system/shop-app.service
|
||
|
- content: |
|
||
|
server {
|
||
|
listen 80;
|
||
|
server_name default;
|
||
|
location / {
|
||
|
proxy_pass http://127.0.0.1:5000;
|
||
|
proxy_http_version 1.1;
|
||
|
proxy_set_header Upgrade $http_upgrade;
|
||
|
proxy_set_header Connection keep-alive;
|
||
|
proxy_set_header Host $host;
|
||
|
proxy_cache_bypass $http_upgrade;
|
||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||
|
}
|
||
|
}
|
||
|
path: /home/ubuntu/nginx
|
||
|
runcmd:
|
||
|
- sudo cd ~
|
||
|
- sudo git clone https://gitlab.com/ch-tbz-it/Stud/m346/m346scripts.git
|
||
|
# install mongodb shell
|
||
|
- sudo wget -qO- https://www.mongodb.org/static/pgp/server-6.0.asc | sudo tee /etc/apt/trusted.gpg.d/server-6.0.asc
|
||
|
- sudo echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
||
|
- sudo apt-get update
|
||
|
- sudo apt-get install -y mongodb-mongosh
|
||
|
# import mongodb collections
|
||
|
- mongosh "mongodb+srv://[[Mongodb-Cluster-URL]]/" --u [[Mongodb-username]] -p [[Mongodb-password]] < ~/KN06/shop-database-mongodb.txt
|
||
|
# install App
|
||
|
- sudo mkdir /var/www
|
||
|
- sudo mkdir /var/www/app
|
||
|
- sudo sed -i 's/<clusterUrl>/[[Mongodb-Cluster-URL]]/g' ./m346scripts/KN06/dotnet/appsettings.json
|
||
|
- sudo sed -i 's/<username>/[[Mongodb-username]]/g' ./m346scripts/KN06/dotnet/appsettings.json
|
||
|
- sudo sed -i 's/<password>/[[Mongodb-password]]/g' ./m346scripts/KN06/dotnet/appsettings.json
|
||
|
- sudo cp -r ./m346scripts/KN06/dotnet/* /var/www/app/
|
||
|
- sudo systemctl enable shop-app.service
|
||
|
- sudo systemctl start shop-app.service
|
||
|
- sudo service nginx start
|
||
|
- sudo cp /home/ubuntu/nginx /etc/nginx/sites-available/default
|
||
|
- sudo nginx -s reload
|
||
|
|