Skip to content

Commit 2d2b1a6

Browse files
committed
build: update config/deploy.yml
1 parent baa5e05 commit 2d2b1a6

File tree

9 files changed

+186
-6
lines changed

9 files changed

+186
-6
lines changed

.dockerignore

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2+
# Ignore git directory
3+
/.git/
4+
5+
# Ignore all environment files (except templates)
6+
/.env*
7+
!/.env.example
8+
9+
# Ignore all logfiles and tempfiles
10+
/storage/logs/*
11+
!/storage/logs/.gitkeep
12+
/storage/framework/cache/*
13+
!/storage/framework/cache/.gitkeep
14+
/storage/framework/sessions/*
15+
!/storage/framework/sessions/.gitkeep
16+
/storage/framework/testing/*
17+
!/storage/framework/testing/.gitkeep
18+
/storage/framework/views/*
19+
!/storage/framework/views/.gitkeep
20+
/storage/app/*
21+
!/storage/app/.gitkeep
22+
/storage/app/public/*
23+
!/storage/app/public/.gitkeep
24+
25+
# Ignore temporary files
26+
/bootstrap/cache/*
27+
!/bootstrap/cache/.gitkeep
28+
29+
# Ignore dependencies
30+
/node_modules/
31+
/vendor/
32+
33+
# Ignore compiled assets
34+
/public/build/*
35+
/public/hot
36+
/public/storage
37+
/public/css
38+
/public/js
39+
/public/mix-manifest.json
40+
41+
# IDE specific files
42+
/.idea
43+
/.vscode
44+
/.fleet
45+
/.phpstorm.meta.php
46+
/_ide_helper*.php
47+
48+
# Testing and documentation
49+
/phpunit.xml
50+
/.phpunit.cache
51+
/tests/coverage
52+
/docs

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ PADDLE_WEBHOOK_SECRET=pdl_...
6767
STRIPE_PUBLISHABLE_KEY=pk_test_...
6868
STRIPE_SECRET_KEY=sk_test_...
6969
STRIPE_WEBHOOK_SECRET=whsec_...
70+
71+
PROD_HOST=site-domain
72+
SSH_HOST=ssh-ip-address

.kamal/hooks/docker-setup

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
ssh root@$KAMAL_HOSTS 'bash -s' <.kamal/hooks/setup-server.sh

.kamal/hooks/setup-server.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker network inspect private || docker network create -d bridge private

.kamal/secrets

+5
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
1515
# SECRETS=$(kamal secrets fetch --adapter 1password --account my-account --from MyVault/MyItem KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
1616
# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD $SECRETS)
1717
# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS)
18+
19+
APP_KEY=$APP_KEY
20+
AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
21+
AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
22+
DB_PASSWORD=$DB_PASSWORD

Dockerfile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM serversideup/php:8.4-unit AS base
2+
ENV AUTORUN_ENABLED=true PHP_OPCACHE_ENABLE=1
3+
WORKDIR /var/www/html/
4+
USER root
5+
RUN apt-get update && install-php-extensions gd exif intl
6+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
7+
8+
FROM base AS deps
9+
COPY composer.* ./
10+
USER www-data
11+
RUN composer install --no-dev --no-interaction --no-scripts --prefer-dist
12+
13+
FROM node:22-slim AS frontend
14+
WORKDIR /app
15+
COPY package*.json *.config.js ./
16+
COPY public/ ./public
17+
COPY resources/ ./resources
18+
COPY --from=deps /var/www/html/vendor ./vendor
19+
RUN npm ci && npm run build
20+
21+
FROM base
22+
COPY --chown=www-data:www-data . .
23+
COPY --from=deps --chown=www-data:www-data /var/www/html/vendor ./vendor
24+
COPY --from=frontend --chown=www-data:www-data /app/public/build ./public/build
25+
26+
RUN composer dump-autoload --classmap-authoritative --no-dev --no-interaction --no-scripts --optimize
27+
USER root
28+
RUN rm -rf /usr/bin/composer
29+
30+
USER www-data
31+
COPY --chmod=755 ./entrypoint.d/ /etc/entrypoint.d/

config/deploy.yml

+81-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# Name of your application. Used to uniquely configure containers.
2-
service: my-app
2+
service: wave
33

4-
# Name of the container image.
5-
image: my-user/my-app
4+
# Name of the container image. Change ronald2wing to your username
5+
image: ronald2wing/wave
66

77
# Deploy to these servers.
88
servers:
9+
cron:
10+
cmd: php /var/www/html/artisan schedule:work
11+
hosts:
12+
- <%= ENV['SSH_HOST'] %>
13+
options:
14+
health-cmd: pgrep -f "php artisan schedule:work" || exit 1
15+
network: private
916
web:
10-
- 192.168.0.1
17+
hosts:
18+
- <%= ENV['SSH_HOST'] %>
19+
options:
20+
network: private
1121
# job:
1222
# hosts:
1323
# - 192.168.0.1
@@ -18,16 +28,18 @@ servers:
1828
#
1929
# Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
2030
proxy:
31+
app_port: 8080
32+
host: <%= ENV['PROD_HOST'] %>
2133
ssl: true
22-
host: app.example.com
2334
# Proxy connects to your container on port 80 by default.
2435
# app_port: 3000
2536

2637
# Credentials for your image host.
2738
registry:
2839
# Specify the registry server, if you're not using Docker Hub
2940
# server: registry.digitalocean.com / ghcr.io / ...
30-
username: my-user
41+
# Change ronald2wing to your username
42+
username: ronald2wing
3143

3244
# Always use an access token rather than real password (pulled from .kamal/secrets).
3345
password:
@@ -47,12 +59,30 @@ builder:
4759
# DB_HOST: 192.168.0.2
4860
# secret:
4961
# - RAILS_MASTER_KEY
62+
env:
63+
clear:
64+
APP_DEBUG: false
65+
APP_ENV: production
66+
APP_NAME: Wave
67+
APP_URL: https://<%= ENV['PROD_HOST'] %>
68+
DB_CONNECTION: mysql
69+
DB_DATABASE: wave_production
70+
DB_HOST: wave-db
71+
DB_USERNAME: wave
72+
REDIS_HOST: wave-redis
73+
SESSION_DRIVER: redis
74+
secret:
75+
- APP_KEY
76+
- DB_PASSWORD
5077

5178
# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
5279
# "bin/kamal app logs -r job" will tail logs from the first server in the job section.
5380
#
5481
# aliases:
5582
# shell: app exec --interactive --reuse "bash"
83+
aliases:
84+
shell: app exec --interactive --reuse "bash"
85+
tinker: app exec --interactive --reuse "php artisan tinker"
5686

5787
# Use a different ssh user than root
5888
#
@@ -69,6 +99,7 @@ builder:
6999
# version inside the asset_path.
70100
#
71101
# asset_path: /app/public/assets
102+
asset_path: /var/www/html/public/build
72103

73104
# Configure rolling deploys by setting a wait time between batches of restarts.
74105
#
@@ -99,3 +130,47 @@ builder:
99130
# port: 6379
100131
# directories:
101132
# - data:/data
133+
accessories:
134+
db:
135+
directories:
136+
- data:/var/lib/mysql
137+
env:
138+
clear:
139+
MYSQL_DATABASE: wave_production
140+
MYSQL_PASSWORD: <%= ENV['DB_PASSWORD'] %>
141+
MYSQL_ROOT_PASSWORD: <%= ENV['DB_PASSWORD'] %>
142+
MYSQL_USER: wave
143+
host: <%= ENV['SSH_HOST'] %>
144+
image: mysql:9.3
145+
options:
146+
network: private
147+
db_backup:
148+
env:
149+
clear:
150+
AWS_BUCKET_NAME: wave
151+
AWS_DEFAULT_REGION: us-east-1
152+
DB_DUMP_INCLUDE: wave_production
153+
DB_DUMP_RETENTION: 30d
154+
DB_DUMP_TARGET: s3://wave/backups/
155+
DB_NAME: wave_production
156+
DB_PASS: <%= ENV['DB_PASSWORD'] %>
157+
DB_RESTORE_TARGET: s3://wave/backups/
158+
DB_SERVER: wave-db
159+
DB_USER: wave
160+
SINGLE_DATABASE: true
161+
secret:
162+
- AWS_ACCESS_KEY_ID
163+
- AWS_SECRET_ACCESS_KEY
164+
host: <%= ENV['SSH_HOST'] %>
165+
image: databack/mysql-backup:1.2.2
166+
options:
167+
network: private
168+
volumes:
169+
- backup-data:/db
170+
redis:
171+
directories:
172+
- redis-data:/data
173+
host: <%= ENV['SSH_HOST'] %>
174+
image: valkey/valkey:8.1.1
175+
options:
176+
network: private
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
artisan filament:upgrade
4+
artisan route:clear

routes/web.php

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616

1717
// Wave routes
1818
Wave::routes();
19+
20+
Route::get('/up', function () {
21+
return response('OK', 200);
22+
});

0 commit comments

Comments
 (0)