-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JaroslawCzerwinski
authored and
JaroslawCzerwinski
committed
Sep 19, 2023
0 parents
commit f1020d7
Showing
55 changed files
with
1,463 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Deploy on dev | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'App version to deploy' | ||
required: true | ||
default: '1.0.0' | ||
|
||
env: | ||
ENVIRONMENT: dev | ||
REGION: eu-central-1 | ||
TEAM: Platform-Engineering | ||
|
||
jobs: | ||
release: | ||
name: Deploy workoutrecorder-frontend | ||
runs-on: [self-hosted, dev] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Pull SSH key for Ansible connection | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/post-provisioning/app_${{ env.ENVIRONMENT }}_key.pem \ | ||
app_${{ env.ENVIRONMENT }}_key.pem | ||
chmod 600 app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Download artifact | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/release/workoutrecorder-frontend-${{ github.event.inputs.version }}.zip \ | ||
workoutrecorder-frontend-${{ github.event.inputs.version }}.zip | ||
- name: Ansible Playbook | ||
run: | | ||
cd ansible | ||
ansible-playbook \ | ||
deploy.yaml \ | ||
-i ./inventories/${{ env.ENVIRONMENT }}/inventory_aws_ec2.yaml \ | ||
-extra-vars="app_version=${{ github.event.inputs.version }}" \ | ||
--private-key app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Remove SSH key | ||
if: always() | ||
run: | | ||
cd ansible | ||
rm app_${{ env.ENVIRONMENT }}_key.pem -f | ||
continue-on-error: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Deploy on prod | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'App version to deploy' | ||
required: true | ||
default: '1.0.0' | ||
|
||
env: | ||
ENVIRONMENT: prod | ||
REGION: eu-central-1 | ||
TEAM: Platform-Engineering | ||
|
||
jobs: | ||
release: | ||
name: Deploy workoutrecorder-frontend | ||
runs-on: [self-hosted, prod] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Pull SSH key for Ansible connection | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/post-provisioning/app_${{ env.ENVIRONMENT }}_key.pem \ | ||
app_${{ env.ENVIRONMENT }}_key.pem | ||
chmod 600 app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Download artifact | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/release/workoutrecorder-frontend-${{ github.event.inputs.version }}.zip \ | ||
workoutrecorder-frontend-${{ github.event.inputs.version }}.zip | ||
- name: Ansible Playbook | ||
run: | | ||
cd ansible | ||
ansible-playbook \ | ||
deploy.yaml \ | ||
-i ./inventories/${{ env.ENVIRONMENT }}/inventory_aws_ec2.yaml \ | ||
-extra-vars="app_version=${{ github.event.inputs.version }}" \ | ||
--private-key app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Remove SSH key | ||
if: always() | ||
run: | | ||
cd ansible | ||
rm app_${{ env.ENVIRONMENT }}_key.pem -f | ||
continue-on-error: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Deploy on uat | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'App version to deploy' | ||
required: true | ||
default: '1.0.0' | ||
|
||
env: | ||
ENVIRONMENT: uat | ||
REGION: eu-central-1 | ||
TEAM: Platform-Engineering | ||
|
||
jobs: | ||
release: | ||
name: Deploy workoutrecorder-frontend | ||
runs-on: [self-hosted, uat] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Pull SSH key for Ansible connection | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/post-provisioning/app_${{ env.ENVIRONMENT }}_key.pem \ | ||
app_${{ env.ENVIRONMENT }}_key.pem | ||
chmod 600 app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Download artifact | ||
run: | | ||
cd ansible | ||
aws s3 cp \ | ||
s3://red-devops-workout-recorder/release/workoutrecorder-frontend-${{ github.event.inputs.version }}.zip \ | ||
workoutrecorder-frontend-${{ github.event.inputs.version }}.zip | ||
- name: Ansible Playbook | ||
run: | | ||
cd ansible | ||
ansible-playbook \ | ||
deploy.yaml \ | ||
-i ./inventories/${{ env.ENVIRONMENT }}/inventory_aws_ec2.yaml \ | ||
-extra-vars="app_version=${{ github.event.inputs.version }}" \ | ||
--private-key app_${{ env.ENVIRONMENT }}_key.pem | ||
- name: Remove SSH key | ||
if: always() | ||
run: | | ||
cd ansible | ||
rm app_${{ env.ENVIRONMENT }}_key.pem -f | ||
continue-on-error: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Release workoutrecorder-frontend | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'App version to release' | ||
required: true | ||
default: '1.0.0' | ||
fabioip: | ||
description: 'Public fabio ip addres' | ||
required: true | ||
|
||
jobs: | ||
release: | ||
name: Release workoutrecorder-frontend | ||
runs-on: self-hosted | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
|
||
- name: Set app version | ||
run: | | ||
version=${{ github.event.inputs.version }} | ||
sed -i "s/<VERSION>/$version/g" frontend/package.json | ||
- name: Set fabio public ip | ||
run: | | ||
fabioip=${{ github.event.inputs.fabioip }} | ||
sed -i "s/<FABIO_PUBLIC_IP>/$fabioip/g" frontend/src/environments/environment.prod.ts | ||
- name: Install dependency | ||
run: | | ||
mkdir app | ||
cp frontend/package.json app | ||
cd app | ||
npm install | ||
- name: Build and Package | ||
run: | | ||
cp frontend/* app -r | ||
cd app | ||
npm run build --prod | ||
zip -jr workoutrecorder-frontend-${{ github.event.inputs.version }}.zip dist/workoutrecorder-front/* | ||
- name: Upload Release | ||
run: | | ||
aws s3 cp \ | ||
app/workoutrecorder-frontend-${{ github.event.inputs.version }}.zip \ | ||
s3://red-devops-workout-recorder/release/workoutrecorder-frontend-${{ github.event.inputs.version }}.zip |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Red-DevOps | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Workoutrecorder - Frontend App | ||
|
||
The content of this project is part of the post on blog https://red-devops.pl/ <br> | ||
The repository consists of two parts. The first part contained in the frontend folder contains the source code of the Angular application. The second part of the application, contained in the ansibl folder, contains the Ansible playbook that deploys applications to remote servers. This repository is part of a larger workout-recorder project which can be found here https://github.com/red-devops/Workout-recorder-consul. The application should be deployed on hoset after executing the HashiCorp Terraform from folder 100-app-infra/180-instances from the main repo. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[defaults] | ||
remote_user = ubuntu | ||
host_key_checking = False | ||
enable_plugins = host_list, virtualbox, yaml, constructed, aws_ec2, script, ini, auto, toml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: Deploy workoutrecorder backend | ||
hosts: all | ||
become: true | ||
roles: | ||
|
||
- role: prerequisites | ||
tags: | ||
- prerequisites | ||
|
||
- role: consul | ||
tags: | ||
- consul | ||
|
||
- role: frontend | ||
tags: | ||
- frontend |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#APP | ||
app: "frontend" | ||
user: frontend | ||
group: frontend | ||
mode: u+rwx,g+r,o+r | ||
app_port: 80 | ||
app_home: "/home/{{ user }}" | ||
app_data: "{{ app_home }}/data" | ||
app_config_home: "{{ app_home }}/config" | ||
app_bin_home: "{{ app_home }}/bin" | ||
app_log_home: "{{ app_home }}/log" | ||
app_version: 1.0.0 | ||
sites_available_dir: /etc/nginx/sites-available | ||
|
||
#AWS | ||
region: "eu-central-1" | ||
|
||
#Consul | ||
consul_bootstrap_secret_name: Consul-Global-Managemen-Token-{{ env }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Dev environment | ||
env: dev |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[all] | ||
localhost ansible_connection=local |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
plugin: aws_ec2 | ||
regions: | ||
- "eu-central-1" | ||
filters: | ||
instance-state-name: running | ||
tag:Name: EC2-dev-frontend-ASG | ||
tag:Environment: dev | ||
tag:ostype: linux | ||
compose: | ||
private_ip_address: private_ip_address | ||
hostnames: | ||
- private-ip-address |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Prod environment | ||
env: prod |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[all] | ||
localhost ansible_connection=local |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
plugin: aws_ec2 | ||
regions: | ||
- "eu-central-1" | ||
filters: | ||
instance-state-name: running | ||
tag:Name: EC2-prod-backend-ASG | ||
tag:Environment: prod | ||
tag:ostype: linux | ||
compose: | ||
private_ip_address: private_ip_address | ||
hostnames: | ||
- private-ip-address |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Uat environment | ||
env: uat |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[all] | ||
localhost ansible_connection=local |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
plugin: aws_ec2 | ||
regions: | ||
- "eu-central-1" | ||
filters: | ||
instance-state-name: running | ||
tag:Name: EC2-uat-backend-ASG | ||
tag:Environment: uat | ||
tag:ostype: linux | ||
compose: | ||
private_ip_address: private_ip_address | ||
hostnames: | ||
- private-ip-address |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# Defaults for consul agent |
Oops, something went wrong.