Last active
December 10, 2020 07:19
-
-
Save VasylShevchenko/c33ed2d749cd53b9c5c7cec7d36f5d35 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) Go to bitbucket add ssh key Known hosts | |
// Add server id_rsa.pub to this link | |
https://bitbucket.org/winstrategy/NAME_PROJECT/admin/access-keys/ | |
// Generate SSH pub and private and add pub to server | |
https://bitbucket.org/winstrategy/NAME_PROJECT/admin/addon/admin/pipelines/ssh-keys | |
// Add dotnet service | |
deployer$ sudo vim /etc/systemd/system/dotnet.service | |
insert dotnet.service | |
// Restart systemd | |
deployer$ sudo systemctl daemon-reload | |
// Check service | |
$ sudo systemctl start dotnet.service | |
$ sudo systemctl stop dotnet.service | |
$ sudo systemctl restart dotnet.service | |
$ sudo systemctl status dotnet.service | |
// Enable service | |
$ sudo systemctl enable dotnet.service | |
deployer$ sudo visudo | |
// add | |
deployer ALL=NOPASSWD: /bin/systemctl restart nginx, /bin/systemctl status nginx | |
deployer ALL=NOPASSWD: /bin/systemctl restart dotnet.service, /bin/systemctl status dotnet.service | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Deploy script start (deploy.sh)" | |
echo "" | |
echo "Git fetch ($ git fetch --all && git reset --hard origin/master)" | |
git fetch --all | |
git reset --hard origin/master | |
echo "" | |
echo "Restart DotNet ($ sudo /bin/systemctl restart name.service)" | |
sudo /bin/systemctl restart dotnet.service | |
sudo /bin/systemctl status dotnet.service | |
echo "" | |
echo "Restart Nginx ($ sudo /bin/systemctl restart nginx)" | |
sudo /bin/systemctl restart nginx | |
sudo /bin/systemctl status nginx | |
echo "Deploy script finish (deploy.sh)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: atlassian/default-image:latest | |
pipelines: | |
default: | |
- step: | |
deployment: production | |
script: | |
# - cat ./deploy.sh | ssh deployer@IP_SERVER | |
- echo "Deploy" | |
- ssh deployer@IP_SERVER 'cd /home/deployer/apps/app-name && sh bitbucket-deploy.sh && exit' | |
- echo "Deploy step finished" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Example .NET Web API App running on Ubuntu | |
[Service] | |
WorkingDirectory=/home/deployer/apps/NAME_PROJECT | |
ExecStart=/usr/bin/dotnet /home/deployer/apps/NAME_PROJECT/NAME_PROJECT.dll | |
Restart=always | |
# Restart service after 10 seconds if the dotnet service crashes: | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment