Skip to content

Commit 057bbe9

Browse files
committed
Update workflow and compose file
1 parent 44a932d commit 057bbe9

4 files changed

Lines changed: 80 additions & 72 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,62 @@ concurrency:
99

1010
jobs:
1111
deploy:
12+
name: Deploy Server
1213
runs-on: ubuntu-latest
1314

1415
steps:
1516
- name: 🛎️ Checkout Repository
1617
uses: actions/checkout@v4
1718

18-
- name: 🔐 SSH Key & .env setup
19-
run: |
20-
mkdir -p ~/.ssh
21-
chmod 700 ~/.ssh
22-
echo "${{ secrets.SSH_SECRET }}" > ~/.ssh/bitanon.pem
23-
chmod 600 ~/.ssh/bitanon.pem
24-
echo "${{ secrets.ENV_FILE }}" > .env
25-
26-
# - name: 🐳 Build Docker Image
27-
# run: docker build -t lncrawl .
19+
- name: 🔐 Login to GitHub Container Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.GITHUB_TOKEN }}
2825

2926
- name: 🐳 Set up Docker Buildx
3027
uses: docker/setup-buildx-action@v3
3128

32-
- name: 💾 Docker Cache
33-
uses: actions/cache@v4
34-
with:
35-
path: /tmp/.buildx-cache
36-
key: ${{ runner.os }}-buildx-${{ github.sha }}
37-
restore-keys: |
38-
${{ runner.os }}-buildx-
29+
- name: 📝 Create .env file for Docker build
30+
run: touch .env
3931

40-
- name: 🐳 Build Docker Image with Cache
32+
- name: 🏗️ Build and push Container image
4133
uses: docker/build-push-action@v5
4234
with:
4335
context: .
44-
tags: lncrawl:latest
36+
platforms: linux/amd64
37+
push: true
38+
tags: ghcr.io/${{ github.repository }}:latest
39+
labels: |
40+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
41+
org.opencontainers.image.revision=${{ github.sha }}
4542
outputs: type=docker,dest=/tmp/lncrawl.tar
46-
cache-from: type=local,src=/tmp/.buildx-cache
47-
cache-to: type=local,dest=/tmp/.buildx-cache
43+
cache-from: type=gha
44+
cache-to: type=gha,mode=max
45+
46+
- name: 🛡️ Setup SSH Key
47+
run: |
48+
mkdir -p ~/.ssh
49+
chmod 700 ~/.ssh
50+
echo "${{ secrets.SSH_SECRET }}" > ~/.ssh/id_rsa
51+
chmod 600 ~/.ssh/id_rsa
52+
ssh-keyscan -H "${{ secrets.DEPLOY_SERVER }}" >> ~/.ssh/known_hosts
4853
4954
- name: 📦 Transfer Docker Image
5055
run: |
51-
bzip2 < /tmp/lncrawl.tar | \
52-
ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
53-
"${{ secrets.DEPLOY_SERVER }}" 'bunzip2 | docker load'
56+
bzip2 < /tmp/lncrawl.tar | ssh "${{ secrets.DEPLOY_SERVER }}" 'bunzip2 | docker load'
5457
55-
# - name: 📦 Save and Transfer Docker Image
56-
# run: |
57-
# docker save lncrawl | bzip2 | \
58-
# ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
59-
# "${{ secrets.DEPLOY_SERVER }}" docker load
58+
- name: 📤 Upload Compose File
59+
run: |
60+
scp ./scripts/server-compose.yml "${{ secrets.DEPLOY_SERVER }}:~/lncrawl/compose.yml"
6061
61-
- name: 🏗️ Prepare server environment
62+
- name: 🚀 Deploy over SSH
6263
run: |
63-
ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
64-
"${{ secrets.DEPLOY_SERVER }}" << 'EOF'
64+
ssh "${{ secrets.DEPLOY_SERVER }}" << 'EOF'
6565
mkdir -p ~/lncrawl/output_path
6666
cd ~/lncrawl
67-
touch .env sqlite.db
68-
chown 1000:1000 .env sqlite.db output_path
67+
touch .env
68+
chown 1000:1000 .env output_path
69+
docker compose -f ~/lncrawl/compose.yml up -d
6970
EOF
70-
71-
- name: 📂 Upload Compose File
72-
run: |
73-
scp -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
74-
./scripts/server-compose.yml \
75-
"${{ secrets.DEPLOY_SERVER }}:~/lncrawl/compose.yml"
76-
77-
- name: 🚀 Run Container via Docker Compose
78-
run: |
79-
ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
80-
"${{ secrets.DEPLOY_SERVER }}" \
81-
"docker compose -f ~/lncrawl/compose.yml up -d"

.github/workflows/release.yml

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,43 +164,30 @@ jobs:
164164
steps:
165165
- uses: actions/checkout@v4
166166

167-
- name: Login to GitHub Container Registry
167+
- name: 🔐 Login to GitHub Container Registry
168168
uses: docker/login-action@v3
169169
with:
170170
registry: ghcr.io
171171
username: ${{ github.actor }}
172172
password: ${{ secrets.GITHUB_TOKEN }}
173173

174-
- name: Set up Docker Buildx
174+
- name: 🐳 Set up Docker Buildx
175175
uses: docker/setup-buildx-action@v3
176176

177-
- name: Extract version
178-
id: version
179-
run: |
180-
VERSION=${GITHUB_REF_NAME#v}
181-
echo "VERSION=$VERSION" >> $GITHUB_ENV
182-
echo "version=$VERSION" >> $GITHUB_OUTPUT
183-
184177
- name: 📝 Create .env file for Docker build
185-
run: |
186-
touch .env
178+
run: touch .env
187179

188-
- name: 🏗️ Build and push Container image
180+
- name: 🏗️ Build and Push Image
189181
uses: docker/build-push-action@v5
190182
with:
191183
context: .
192184
platforms: linux/amd64
193185
push: true
194186
tags: |
195187
ghcr.io/${{ github.repository }}:latest
196-
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
188+
ghcr.io/${{ github.repository }}:${GITHUB_REF##*/}
197189
labels: |
198190
org.opencontainers.image.source=${{ github.event.repository.html_url }}
199191
org.opencontainers.image.revision=${{ github.sha }}
200192
cache-from: type=gha
201193
cache-to: type=gha,mode=max
202-
203-
- name: 🧪 Test Container
204-
run: |
205-
# Test listing sources
206-
docker run --rm ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} --list-sources

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ sqlmodel
3838
passlib[argon2]
3939
python-jose[cryptography]
4040
python-dateutil
41+
psycopg[binary]
4142

4243
# dev requirements
4344
wheel

scripts/server-compose.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
services:
22
chrome:
33
image: selenium/standalone-chrome:latest
4-
cpus: 1.5
5-
mem_limit: 1600m
64
shm_size: 6gb
75
restart: unless-stopped
86
ports:
97
- "7900:7900"
10-
- "4444:4444"
118
environment:
129
SE_VNC_VIEW_ONLY: "1"
1310
SE_EVENT_BUS_PUBLISH_PORT: "4442"
@@ -18,11 +15,35 @@ services:
1815
SE_SCREEN_WIDTH: "1920"
1916
SE_SCREEN_HEIGHT: "1080"
2017
SE_NODE_GRID_URL: "false"
18+
deploy:
19+
resources:
20+
limits:
21+
cpus: '1.50'
22+
memory: 2G
23+
reservations:
24+
cpus: '1.00'
25+
memory: 1G
26+
27+
postgres:
28+
image: postgres:alpine
29+
restart: unless-stopped
30+
environment:
31+
POSTGRES_USER: pguser
32+
POSTGRES_PASSWORD: pgpass
33+
POSTGRES_DB: lncrawl
34+
volumes:
35+
- pgdata:/var/lib/postgresql/data
36+
deploy:
37+
resources:
38+
limits:
39+
cpus: '0.50'
40+
memory: 512M
41+
reservations:
42+
cpus: '0.25'
43+
memory: 256M
2144

2245
server:
2346
image: lncrawl
24-
cpus: 1.8
25-
mem_limit: 3200m
2647
restart: unless-stopped
2748
ports:
2849
- "23457:8000"
@@ -35,13 +56,23 @@ services:
3556
environment:
3657
- PYTHONUNBUFFERED=1
3758
- OUTPUT_PATH=/home/lncrawl/output
38-
- DATABASE_URL=sqlite:////app/sqlite.db
59+
- DATABASE_URL=postgresql+psycopg://pguser:pgpass@postgres:5432/lncrawl
3960
volumes:
4061
- ./output_path:/home/lncrawl/output
41-
- ./sqlite.db:/app/sqlite.db
4262
- ./.env:/app/.env
4363
depends_on:
4464
- chrome
65+
- postgres
4566
extra_hosts:
4667
- "host.docker.internal:host-gateway"
47-
68+
deploy:
69+
resources:
70+
limits:
71+
cpus: '1.50'
72+
memory: 3G
73+
reservations:
74+
cpus: '1.00'
75+
memory: 1G
76+
77+
volumes:
78+
pgdata:

0 commit comments

Comments
 (0)