Skip to content

Commit 618b569

Browse files
committed
fix: performance
1 parent 216d327 commit 618b569

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

.github/workflows/build-and-run.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@ on:
99
jobs:
1010
build:
1111
runs-on: self-hosted
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
1215

1316
steps:
1417
- uses: actions/checkout@v4
1518

19+
- name: Cache Docker layers
20+
uses: actions/cache@v3
21+
with:
22+
path: /tmp/.buildx-cache
23+
key: ${{ runner.os }}-docker-${{ github.sha }}
24+
restore-keys: |
25+
${{ runner.os }}-docker-
26+
1627
- name: Create PostgreSQL data directory
1728
run: |
1829
sudo mkdir -p /root/mydata/postgresql-data
@@ -22,4 +33,4 @@ jobs:
2233
run: sudo docker compose down || true
2334

2435
- name: Build and start Docker containers
25-
run: sudo docker compose up -d --build
36+
run: sudo docker compose up -d --build --cache-from type=local,src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache

docker-compose.yml

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
services:
2-
# caddy:
3-
# image: caddy:latest
4-
# restart: unless-stopped
5-
# ports:
6-
# - "80:80"
7-
# - "443:443"
8-
# - "443:443/udp"
9-
# volumes:
10-
# - ./Caddyfile:/etc/caddy/Caddyfile
11-
# - ./site:/srv
12-
# - caddy_data:/data
13-
# - caddy_config:/config
14-
152
app:
163
build: .
174
ports:
@@ -20,6 +7,11 @@ services:
207
- db
218
environment:
229
- DATABASE_URL=postgresql://user:password@db:5432/database
10+
deploy:
11+
resources:
12+
limits:
13+
cpus: "0.5"
14+
memory: "256M"
2315

2416
db:
2517
image: postgres
@@ -29,8 +21,8 @@ services:
2921
- POSTGRES_DB=database
3022
volumes:
3123
- /root/mydata/postgresql-data:/var/lib/postgresql/data
32-
# volumes:
33-
# caddy_data:
34-
# driver: local
35-
# caddy_config:
36-
# driver: local
24+
deploy:
25+
resources:
26+
limits:
27+
cpus: "0.25"
28+
memory: "512M"

0 commit comments

Comments
 (0)