Skip to content

Commit def3cfa

Browse files
committed
init
0 parents  commit def3cfa

24 files changed

+3228
-0
lines changed

.github/workflows/prod.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build, Test and Deploy to Prod
2+
3+
# Trigger the workflow when changes are pushed to the main branch
4+
on:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Checkout code from the repository
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
19+
# Cache dependencies to speed up build times
20+
- name: Cache dependencies
21+
uses: actions/cache@v3
22+
with:
23+
path: |
24+
app-service/.cargo
25+
app-service/target/
26+
auth-service/.cargo
27+
auth-service/target/
28+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
29+
restore-keys: ${{ runner.os }}-cargo-
30+
31+
- name: Install Rust
32+
run: rustup update stable && rustup default stable
33+
34+
- name: Build and test app-service code
35+
working-directory: ./app-service
36+
run: |
37+
cargo build --verbose
38+
cargo test --verbose
39+
40+
- name: Build and test auth-service code
41+
working-directory: ./auth-service
42+
run: |
43+
cargo build --verbose
44+
cargo test --verbose
45+
46+
# Set up Docker Buildx for multi-platform builds
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v2
49+
50+
- name: Log in to Docker Hub
51+
uses: docker/#-action@v2
52+
with:
53+
username: ${{ secrets.DOCKER_USERNAME }}
54+
password: ${{ secrets.DOCKER_PASSWORD }}
55+
56+
- name: Build and push Docker images
57+
uses: docker/bake-action@v2.3.0
58+
with:
59+
push: true
60+
files: |
61+
compose.yml
62+
compose.override.yml
63+
set: |
64+
*.cache-from=type=gha
65+
*.cache-to=type=gha,mode=max
66+
67+
deploy:
68+
needs: build
69+
runs-on: ubuntu-latest
70+
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v2
74+
75+
- name: Log in to Docker Hub
76+
uses: docker/#-action@v1
77+
with:
78+
username: ${{ secrets.DOCKER_USERNAME }}
79+
password: ${{ secrets.DOCKER_PASSWORD }}
80+
81+
- name: Install sshpass
82+
run: sudo apt-get install sshpass
83+
84+
- name: Copy compose.yml to droplet
85+
run: sshpass -v -p ${{ secrets.DROPLET_PASSWORD }} scp -o StrictHostKeyChecking=no compose.yml root@${{ vars.DROPLET_IP }}:~
86+
87+
- name: Deploy
88+
uses: appleboy/ssh-action@master
89+
with:
90+
host: ${{ vars.DROPLET_IP }}
91+
username: root
92+
password: ${{ secrets.DROPLET_PASSWORD }}
93+
script: |
94+
cd ~
95+
export AUTH_SERVICE_IP=${{ vars.DROPLET_IP }}
96+
docker compose down
97+
docker compose pull
98+
docker compose up -d

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Setup & Building
2+
```bash
3+
cargo install cargo-watch
4+
cd app-service
5+
cargo build
6+
cd ..
7+
cd auth-service
8+
cargo build
9+
cd ..
10+
```
11+
12+
## Run servers locally (Manually)
13+
#### App service
14+
```bash
15+
cd app-service
16+
cargo watch -q -c -w src/ -w assets/ -w templates/ -x run
17+
```
18+
19+
visit http://localhost:8000
20+
21+
#### Auth service
22+
```bash
23+
cd auth-service
24+
cargo watch -q -c -w src/ -w assets/ -x run
25+
```
26+
27+
visit http://localhost:3000
28+
29+
## Run servers locally (Docker)
30+
```bash
31+
docker compose build
32+
docker compose up
33+
```
34+
35+
visit http://localhost:8000 and http://localhost:3000

app-service/.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.env
2+
target/
3+
tests/
4+
Dockerfile

app-service/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)