feat: Add items website code base + drone pipeline #9
@ -1,2 +1,2 @@
|
||||
[host]
|
||||
{{ DEPLOYMENT_USER }}@{{ DEPLOY_HOST }} ansible_connection=ssh ansible_user={{ DEPLOYMENT_USER }}
|
||||
{{ DEPLOYMENT_USER }}@{{ DEPLOY_HOSTNAME }} ansible_connection=ssh ansible_user={{ DEPLOYMENT_USER }}
|
@ -6,7 +6,7 @@
|
||||
- name: Debug
|
||||
debug:
|
||||
msg: "{{ lookup('env', 'SPT_ITEMS_PATH') }}"
|
||||
- name: Delete spt-item-finder before adding everything again
|
||||
- name: Delete spt-items-api before adding everything again
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}"
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
- name: Initialize database
|
||||
uri:
|
||||
url: "https://{{ lookup('env', 'SPT_HOSTNAME') }}/api/refresh"
|
||||
url: "https://{{ lookup('env', 'SPT_ITEM_HOSTNAME') }}/api/refresh"
|
||||
method: GET
|
||||
status_code: [200, 204]
|
||||
timeout: 60
|
@ -2,7 +2,7 @@ APP_NAME="Item Finder"
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
APP_URL="https://{{ lookup('env', 'SPT_HOSTNAME') }}"
|
||||
APP_URL="https://{{ lookup('env', 'SPT_ITEMS_HOSTNAME') }}"
|
||||
APP_TIMEZONE=UTC
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
@ -3,12 +3,11 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon"
|
||||
href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAB2pJREFUWEfFl31sU9cVwP0+fN8nfv5O5BXPIczLIlRlTZZVKCDWTcnoH51EYaNsYlXHEENoY+tGw6e8KAIWRSrZoMoY01D/YFVAkVa6ULYWhYoyQKg0HcpCBK0VEs/Mcez38p7fu/c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OpJCvmybBlWd/BMgRB5BmGOdLd3X0cN6qq7wU0Td+wLOvrJQBBEL6Vy+VGWJY9oev6vmqtFs/jjpnNZnGj8pQdcpeDweC2qgC4Jeu6/ioGCAQCO+bm5l4DAPQpioKbVc0fr9fbDCF8Kp/PR23bXoW/DMMMVwUIBAL16XT6PkVRHx48eHB9Lf29ZqpaX04jkYg7k8m0l+76n8dANdn/AtiRvUnb47ydAAAAAElFTkSuQmCC" />
|
||||
<link rel="icon" href="/favico.svg" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="description" content="item finder" />
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<meta name="description" content="items finder" />
|
||||
<link rel="apple-touch-icon" href="/favico.ico" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<title>Item Finder</title>
|
||||
</head>
|
||||
|
@ -6,7 +6,7 @@ concurrency:
|
||||
limit: 1
|
||||
|
||||
environment:
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-item-api
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-items-api
|
||||
|
||||
|
||||
trigger:
|
||||
event:
|
||||
@ -23,15 +23,15 @@ steps:
|
||||
- name: replace hosts and user variables
|
||||
image: ubuntu:impish
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
commands:
|
||||
- sed -i 's/{{ SPT_HOSTNAME }}/'"$SPT_HOSTNAME"'/g' ./frontend/.env
|
||||
- sed -i 's/{{ DEPLOY_HOST }}/'"$DEPLOY_HOST"'/g' ./.ansible/inventory
|
||||
- sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./frontend/.env
|
||||
- sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible/inventory
|
||||
- sed -i 's/{{ DEPLOYMENT_USER }}/'"$DEPLOYMENT_USER"'/g' ./.ansible/inventory
|
||||
|
||||
- name: build frontend
|
||||
@ -62,10 +62,10 @@ steps:
|
||||
private_key:
|
||||
from_secret: deploy_ssh_key
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
when:
|
||||
|
@ -6,7 +6,7 @@ concurrency:
|
||||
limit: 1
|
||||
|
||||
environment:
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-item-api
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-items-api
|
||||
|
||||
trigger:
|
||||
event:
|
||||
@ -17,25 +17,19 @@ trigger:
|
||||
- development
|
||||
|
||||
steps:
|
||||
- name: fetch and update submodules to the latest commit
|
||||
image: alpine/git
|
||||
commands:
|
||||
- git submodule init
|
||||
- git submodule update --recursive --remote
|
||||
|
||||
- name: replace hosts and user variables
|
||||
image: ubuntu:impish
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
commands:
|
||||
- sed -i 's/{{ SPT_HOSTNAME }}/'"$SPT_HOSTNAME"'/g' ./items/frontend/.env.example
|
||||
- sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./items/frontend/.env.example
|
||||
- mv ./items/frontend/.env.example ./items/frontend/.env
|
||||
- sed -i 's/{{ DEPLOY_HOST }}/'"$DEPLOY_HOST"'/g' ./.ansible-items/inventory
|
||||
- sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible-items/inventory
|
||||
- sed -i 's/{{ DEPLOYMENT_USER }}/'"$DEPLOYMENT_USER"'/g' ./.ansible-items/inventory
|
||||
when:
|
||||
branch:
|
||||
@ -76,10 +70,10 @@ steps:
|
||||
private_key:
|
||||
from_secret: deploy_ssh_key
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
when:
|
||||
|
@ -18,8 +18,8 @@
|
||||
## Required secrets
|
||||
| secret name | description | example |
|
||||
| :-----------------| :---------- | :------- |
|
||||
| spt_hostname | The remote server where spt-items-finder will be reachable <br> used for the frontend resolution | spt-items.my.server.com |
|
||||
| deploy_host | The remote server where to deploy <br> used by Ansible SSH | my.server.com |
|
||||
| spt_items_hostname | The remote server where spt-items-finder will be reachable <br> used for the frontend resolution | spt-items.my.server.com |
|
||||
| deploy_hostname | The remote server where to deploy <br> used by Ansible SSH | my.server.com |
|
||||
| deploy_username | The default username on the remote server <br> used by Ansible SSH <br> This user must have sudo rights | myuser |
|
||||
| deploy_ssh_key | The **content** of the ssh private key used to connect to the remote server <br> The key needs to be in RSA in "RSA PRIVATE KEY" format <br> The ssh publick key needs to already be in the user used in the remote server ~/.ssh/authorized_keys | -----BEGIN RSA PRIVATE KEY----- <br> The key <br> -----END RSA PRIVATE KEY----- |
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* [Check ansible syntax](#check-ansible-syntax)
|
||||
* [Apply ansible playbook](#apply-ansible-playbook)
|
||||
* [Playbook definition](#playbook-definition)
|
||||
* [Delete old spt-item-finder](#delete-old-spt-item-finder)
|
||||
* [Delete old spt-items-api](#delete-old-spt-items-api)
|
||||
* [Copy the project](#copy-the-project)
|
||||
* [Copy PHP env file](#copy-php-env-file)
|
||||
* [Get JavaScript chunks name](#get-javascript-chunks-name)
|
||||
@ -49,7 +49,7 @@ The pipeline is set to only one build at a time (every subsequent build with be
|
||||
## Environment variables
|
||||
```yml
|
||||
environment:
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-item-api
|
||||
SPT_ITEMS_PATH: /var/www/html/aki/spt-items-api
|
||||
```
|
||||
Here are the environment variables. They are automatically injected in every step.
|
||||
|
||||
@ -79,21 +79,21 @@ Fetching and updating [submodules](https://git-scm.com/book/en/v2/Git-Tools-Subm
|
||||
- name: replace hosts and user variables
|
||||
image: ubuntu:impish
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
commands:
|
||||
- sed -i 's/{{ SPT_HOSTNAME }}/'"$SPT_HOSTNAME"'/g' ./frontend/.env
|
||||
- sed -i 's/{{ DEPLOY_HOST }}/'"$DEPLOY_HOST"'/g' ./.ansible/inventory
|
||||
- sed -i 's/{{ SPT_ITEMS_HOSTNAME }}/'"$SPT_ITEMS_HOSTNAME"'/g' ./frontend/.env
|
||||
- sed -i 's/{{ DEPLOY_HOSTNAME }}/'"$DEPLOY_HOSTNAME"'/g' ./.ansible/inventory
|
||||
- sed -i 's/{{ DEPLOYMENT_USER }}/'"$DEPLOYMENT_USER"'/g' ./.ansible/inventory
|
||||
```
|
||||
Executed on every push. \
|
||||
The following environment variables are injected using Drone secrets:
|
||||
* `SPT_HOSTNAME` is used by the frontend to call the backend.
|
||||
* `DEPLOY_HOST` is used by Ansible to connect to the remote server via SSH.
|
||||
* `SPT_ITEMS_HOSTNAME` is used by the frontend to call the backend.
|
||||
* `DEPLOY_HOSTNAME` is used by Ansible to connect to the remote server via SSH.
|
||||
* `DEPLOYMENT_USER` is used by Ansible to connect to the remote server via SSH.
|
||||
* all environment variables at the pipeline level (see [Environment variables](#environment-variables))
|
||||
Using `sed` makes temporary changes in the container/pod instead of commiting secrets in the repo in plain text. \
|
||||
@ -144,10 +144,10 @@ Check the Ansible syntax in [playbook.yml](../.ansible/playbook.yml), [inventory
|
||||
private_key:
|
||||
from_secret: deploy_ssh_key
|
||||
environment:
|
||||
DEPLOY_HOST:
|
||||
from_secret: deploy_host
|
||||
SPT_HOSTNAME:
|
||||
from_secret: spt_hostname
|
||||
DEPLOY_HOSTNAME:
|
||||
from_secret: deploy_hostname
|
||||
SPT_ITEMS_HOSTNAME:
|
||||
from_secret: spt_items_hostname
|
||||
DEPLOYMENT_USER:
|
||||
from_secret: deploy_username
|
||||
when:
|
||||
@ -160,8 +160,8 @@ Executed only on promotion to production. \
|
||||
This step actually deploys to the server. \
|
||||
This step is [idempotent](https://en.wikipedia.org/wiki/Idempotence). \
|
||||
The following environment variables are injected using Drone secrets:
|
||||
* `SPT_HOSTNAME` is used by the PHP env file.
|
||||
* `DEPLOY_HOST` is used to connect to the remote server via SSH.
|
||||
* `SPT_ITEMS_HOSTNAME` is used by the PHP env file.
|
||||
* `DEPLOY_HOSTNAME` is used to connect to the remote server via SSH.
|
||||
* `DEPLOYMENT_USER` is used to connect to the remote server via SSH.
|
||||
* all environment variables at the pipeline level (see [Environment variables](#environment-variables))
|
||||
|
||||
@ -174,9 +174,9 @@ become_method: sudo
|
||||
```
|
||||
Uses the host defined in [inventory](../.ansible/inventory). Remember, the step [Replace hosts and user variables](#replace-hosts-and-user-variables) already replaced the variables at this point. The playbook will be executed as `root` user using `sudo`.
|
||||
|
||||
#### Delete old spt-item-finder
|
||||
#### Delete old spt-items-api
|
||||
```yml
|
||||
- name: Delete spt-item-finder before adding everything again
|
||||
- name: Delete spt-items-api before adding everything again
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ lookup('env', 'SPT_ITEMS_PATH') }}"
|
||||
@ -202,7 +202,7 @@ Copies the whole project (frontend and backend) from the [api](../api) folder in
|
||||
```
|
||||
Uses [Jinja2](https://jinja2docs.readthedocs.io/en/stable/) to resolve the [template for the PHP .env file](../.ansible/templates/.php_env.j2). \
|
||||
`SPT_ITEMS_PATH` is injected thanks to the pipeline level environment variables (see [Environment variables](#environment-variables)). \
|
||||
`SPT_HOSTNAME` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook))
|
||||
`SPT_ITEMS_HOSTNAME` is injected in the environments properties (see [Apply ansible playbook](#apply-ansible-playbook))
|
||||
|
||||
#### Get JavaScript chunks name
|
||||
```yml
|
||||
|
@ -1,4 +1,4 @@
|
||||
REACT_APP_BACKEND_URL=https://{{ SPT_HOSTNAME }}
|
||||
REACT_APP_BACKEND_URL=https://{{ SPT_ITEMS_HOSTNAME }}
|
||||
REACT_APP_SPTARKOV_HOME=https://www.sp-tarkov.com/
|
||||
REACT_APP_SPTARKOV_WORKSHOP=https://mods.sp-tarkov.com/
|
||||
REACT_APP_SPTARKOV_DOCUMENTATION=https://docs.sp-tarkov.com/
|
Loading…
x
Reference in New Issue
Block a user
Thank you for the review.
I converted the path to a secret. Now we can add it in the Drone instance and even change it without the need to re-release this Drone pipeline.
EDIT: The README has also been updated. Checking if the server complies with the automated process should be easier now