Skip to content

Commit e4572f0

Browse files
- update local environment and prepare dev deployment (#128)
* - pre-prepared files * - update .env's for dev * - update dev Taskfile * - update Dockerfile * - added vite.dev * - spaces * - update renovate.json5 * - update image registry in dev workflow * - update Dockerfile * - add UserSeeder * - update imege registry for dev deployment * - update imege registry for dev deployment * - rename vite env for dev * - update Dockerfile * - update dev deployment files * - update .env.dev * - add trustProxies to app.php * - remove UserSeeder.php * - fixing 403 on non local environment * - update .env.dev and .env.example * - update dev secrets * - update dev secrets * - fix * - update Dockerfile, changed path for frontend build stage * - remove sleep 5 from Taskfile * - add SOPS for dev in .env.example * - update Dockerfile * - update dev php.ini * - add middlewares to docker-compose.dev.yml * - update .env.dev * - update readme.md * - update readme.md * - remove old prod deployment files * - trying out changes in deployment Taskfile * - update local files to work with new blumilk environment * - update .env.example * - added docker rmi in dev workflow for DOCKER_APP_DATABASE_IMAGE_NAME * - update readme.md and .env.example * - update readme.md * - update script in dev workflow * - added dev environment to workflow * - corrections as suggested * - add storage link to post-deploy-actions.sh * - add build-args variable to dev workflow * - fixed link to presentations * - delete unnecessary files * - update supervisord.conf for dev * - add yt link and presentation link to mobile view --------- Co-authored-by: EwelinaSkrzypacz <ewelina.skrzypacz@blumilk.pl>
1 parent 831f1f9 commit e4572f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+901
-547
lines changed

.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.composer/
2+
.editorconfig
3+
.env*
4+
.git/
5+
.gitattributes
6+
.github/
7+
.gitignore
8+
.idea/
9+
.sops.yaml
10+
11+
codestyle.php
12+
docker-compose*
13+
eslint.config.js
14+
Taskfile.yml
15+
node_modules/
16+
phpstan*
17+
public/build/
18+
public/hot
19+
readme.md
20+
renovate.json5
21+
vendor/
22+
23+
/environment
24+
!/environment/.deployment/scripts/post-deploy-actions.sh
25+
!/environment/.docker
26+
!/environment/dev

.env.example

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
55
APP_TIMEZONE=Europe/Warsaw
6-
APP_URL=http://lmt.blumilk.localhost
6+
APP_URL=https://lmt.blumilk.local.env
7+
8+
APP_DOCKER_HOST_NAME=lmt.blumilk.local.env
9+
MAILPIT_DOCKER_HOST_NAME=lmt-mailpit.blumilk.local.env
10+
VITE_DEV_SERVER_DOCKER_HOST_NAME=lmt-vite-dev-server.blumilk.local.env
711

812
APP_LOCALE=pl
913
APP_FALLBACK_LOCALE=en
@@ -21,7 +25,7 @@ LOG_DEPRECATIONS_CHANNEL=null
2125
LOG_LEVEL=debug
2226

2327
DB_CONNECTION=pgsql
24-
DB_HOST=lmt-db-dev
28+
DB_HOST=lmt-db-local
2529
DB_PORT=5432
2630
DB_DATABASE=lmt
2731
DB_USERNAME=lmt
@@ -41,7 +45,7 @@ CACHE_STORE=database
4145
CACHE_PREFIX=
4246

4347
MAIL_MAILER=smtp
44-
MAIL_HOST=lmt-dev-mailpit-container
48+
MAIL_HOST=lmt-mailpit-local
4549
MAIL_PORT=1025
4650
MAIL_USERNAME=null
4751
MAIL_PASSWORD=null
@@ -51,10 +55,13 @@ REGISTRATION_NOTIFICATION_EMAIL="hello@example.com"
5155

5256
VITE_APP_NAME="${APP_NAME}"
5357

58+
SOPS_AGE_DEV_SECRET_KEY=
5459
SOPS_AGE_PROD_SECRET_KEY=
5560

5661
DOCKER_APP_HOST_PORT=8051
5762
DOCKER_DATABASE_HOST_PORT=8055
5863
DOCKER_MAILPIT_DASHBOARD_HOST_PORT=8052
5964

6065
DOCKER_HOST_USER_ID=1000
66+
DOCKER_INSTALL_XDEBUG=false
67+
ALLOWED_EMAIL_DOMAIN=@example.com

.github/workflows/deploy-to-dev.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
DOCKER_REGISTRY_PROJECT_NAME: internal-public
1919
DOCKER_REGISTRY_REPO_NAME: lmt
2020
TARGET_DIR_ON_SERVER: /blumilk/deployments/dev/projects
21+
ENVIRONMENT: dev
2122
steps:
2223
- name: set branch name
2324
run: echo "BRANCH_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV
@@ -27,3 +28,141 @@ jobs:
2728
with:
2829
fetch-depth: 0
2930
ref: ${{ env.BRANCH_NAME }}
31+
32+
- name: sync with main branch
33+
run: |
34+
git config user.name "GitHub Actions Bot"
35+
git config user.email "<>"
36+
git merge --no-commit --no-ff origin/main
37+
38+
- name: set deployment project version
39+
run: echo "DEPLOYMENT_PROJECT_VERSION=$(bash ./environment/.deployment/scripts/version.sh --long)" >> $GITHUB_ENV
40+
41+
- name: set docker image name
42+
run: echo "DOCKER_IMAGE_NAME=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_PROJECT_NAME }}/${{ env.DOCKER_REGISTRY_REPO_NAME }}" >> $GITHUB_ENV
43+
44+
- name: fetch server secrets
45+
uses: Infisical/secrets-action@v1.0.8
46+
with:
47+
domain: https://infisical.blumilk.pl
48+
client-id: ${{ secrets.INFISICAL_MACHINE_IDENTITY_GHA_BOT_CLIENT_ID }}
49+
client-secret: ${{ secrets.INFISICAL_MACHINE_IDENTITY_GHA_BOT_CLIENT_SECRET }}
50+
project-slug: blumilk-infra-pv-ih
51+
env-slug: infra
52+
secret-path: /servers/ovh/ns31445530
53+
export-type: env
54+
recursive: true
55+
include-imports: true
56+
57+
- name: set up Docker Buildx
58+
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
59+
60+
- name: login to Docker Registry
61+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
62+
with:
63+
registry: ${{ env.DOCKER_REGISTRY }}
64+
username: ${{ env.DOCKER_REGISTRY_USER_NAME }}
65+
password: ${{ env.HARBOR_ROBOT_BLUMILKBOT_TOKEN }} # masked secret fetched from Infisical
66+
67+
- name: set docker app database image name
68+
run: echo "DOCKER_APP_DATABASE_IMAGE_NAME=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_PROJECT_NAME }}/${{ env.DOCKER_REGISTRY_REPO_NAME }}-postgres" >> $GITHUB_ENV
69+
70+
71+
- name: Docker meta for app database
72+
id: meta-app-database
73+
uses: docker/metadata-action@v5.5.1
74+
with:
75+
images: |
76+
${{ env.DOCKER_APP_DATABASE_IMAGE_NAME }}
77+
tags: |
78+
type=raw,value=dev
79+
context: workflow
80+
81+
- name: build and push app database image
82+
uses: docker/build-push-action@v5.1.0
83+
with:
84+
context: .
85+
file: ./environment/.docker/postgres/Dockerfile
86+
labels: ${{ steps.meta-app-database.outputs.labels }}
87+
tags: ${{ steps.meta-app-database.outputs.tags }}
88+
push: true
89+
cache-from: type=gha, ref=${{ env.DOCKER_APP_DATABASE_IMAGE_NAME }}-dev-build-cache
90+
cache-to: type=gha, ref=${{ env.DOCKER_APP_DATABASE_IMAGE_NAME }}-dev-build-cache, mode=max
91+
92+
- name: Docker meta for app
93+
id: meta
94+
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
95+
with:
96+
images: ${{ env.DOCKER_IMAGE_NAME }}
97+
tags: |
98+
type=raw,value=dev
99+
context: workflow
100+
101+
- name: build and push app image
102+
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0
103+
with:
104+
context: .
105+
file: ./environment/.docker/app/Dockerfile
106+
target: production
107+
build-args: |
108+
DEPLOYMENT_PROJECT_VERSION_ARG=${{ env.DEPLOYMENT_PROJECT_VERSION }}
109+
ENVIRONMENT=${{ env.ENVIRONMENT }}
110+
labels: ${{ steps.meta.outputs.labels }}
111+
tags: ${{ steps.meta.outputs.tags }}
112+
push: true
113+
cache-from: type=gha, ref=${{ env.DOCKER_IMAGE_NAME }}-dev-build-cache
114+
cache-to: type=gha, ref=${{ env.DOCKER_IMAGE_NAME }}-dev-build-cache, mode=max
115+
116+
- name: set deployment path on server
117+
run: echo "DEPLOYMENT_PATH_ON_SERVER=${{ env.TARGET_DIR_ON_SERVER }}/${{ env.DOCKER_REGISTRY_PROJECT_NAME }}/${{ env.DOCKER_REGISTRY_REPO_NAME }}" >> $GITHUB_ENV
118+
119+
- name: copy files via ssh
120+
uses: appleboy/scp-action@917f8b81dfc1ccd331fef9e2d61bdc6c8be94634 # v0.1.7
121+
with:
122+
timeout: 10s
123+
command_timeout: 10m
124+
host: ${{ env.SERVER_OVH_NS31445530_IP }} # masked secret fetched from Infisical
125+
port: ${{ env.SERVER_OVH_NS31445530_SSH_PORT }} # masked secret fetched from Infisical
126+
username: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_NAME }} # masked secret fetched from Infisical
127+
key: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_SSH_PRIVATE_KEY }} # masked secret fetched from Infisical
128+
passphrase: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_SSH_PRIVATE_KEY_PASSPHRASE }} # masked secret fetched from Infisical
129+
source: "./environment/.deployment/dev/*,./environment/.deployment/Taskfile.yml"
130+
target: ${{ env.DEPLOYMENT_PATH_ON_SERVER }}
131+
rm: true
132+
133+
134+
- name: fetch project deployment secrets
135+
uses: Infisical/secrets-action@v1.0.8
136+
with:
137+
domain: https://infisical.blumilk.pl
138+
client-id: ${{ secrets.INFISICAL_MACHINE_IDENTITY_GHA_BOT_CLIENT_ID }}
139+
client-secret: ${{ secrets.INFISICAL_MACHINE_IDENTITY_GHA_BOT_CLIENT_SECRET }}
140+
project-slug: lmt-d-hr8
141+
env-slug: dev
142+
secret-path: /deployment
143+
export-type: env
144+
recursive: false
145+
include-imports: false
146+
147+
- name: run deployment script over ssh
148+
uses: appleboy/ssh-action@v1.2.2
149+
with:
150+
timeout: 10s
151+
command_timeout: 10m
152+
host: ${{ env.SERVER_OVH_NS31445530_IP }} # masked secret fetched from Infisical
153+
port: ${{ env.SERVER_OVH_NS31445530_SSH_PORT }} # masked secret fetched from Infisical
154+
username: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_NAME }} # masked secret fetched from Infisical
155+
key: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_SSH_PRIVATE_KEY }} # masked secret fetched from Infisical
156+
passphrase: ${{ env.SERVER_OVH_NS31445530_BLUMILKBOT_USER_SSH_PRIVATE_KEY_PASSPHRASE }} # masked secret fetched from Infisical
157+
# masked secrets from Infisical: HARBOR_ROBOT_BLUMILKBOT_TOKEN, SOPS_AGE_DEV_SECRET_KEY
158+
script: |
159+
cd ${{ env.DEPLOYMENT_PATH_ON_SERVER }}/environment/.deployment/
160+
mv Taskfile.yml ${{ env.ENVIRONMENT }}/
161+
cd ${{ env.ENVIRONMENT }}/
162+
echo ${{ env.HARBOR_ROBOT_BLUMILKBOT_TOKEN }} | docker login ${{ env.DOCKER_REGISTRY }} --username ${{ env.DOCKER_REGISTRY_USER_NAME }} --password-stdin
163+
export SOPS_AGE_KEY=${{ env.SOPS_AGE_DEV_SECRET_KEY }}
164+
export ENVIRONMENT=${{ env.ENVIRONMENT }}
165+
task deploy
166+
docker images --filter dangling=true | grep "${{ env.DOCKER_IMAGE_NAME }}" | awk '{print $3}'| xargs --no-run-if-empty docker rmi
167+
docker images --filter dangling=true | grep ${{ env.DOCKER_APP_DATABASE_IMAGE_NAME }} | awk '{print $3}'| xargs --no-run-if-empty docker rmi
168+
docker logout ${{ env.DOCKER_REGISTRY }}

.github/workflows/deploy-to-prod-init.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.idea
22
.vscode
33
/vendor/
4+
*.decrypted
45
.env
5-
.env.prod.secrets.decrypted
66
/cache/*
77
!/cache/.gitkeep
88
node_modules/

.sops.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
creation_rules:
22

3+
- name: dev
4+
path_regex: \.env\.dev\.secrets.*$
5+
age: >-
6+
age1m3ruqh8ldq9wy9w5rpyj2wed0nc0n4ejda2lau2009w2rlvu7qjqacfqp2
7+
38
- name: prod
49
path_regex: \.env\.prod\.secrets.*$
510
age: >-

Makefile

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)