Skip to content

Commit 1fe4784

Browse files
committed
init
0 parents  commit 1fe4784

24 files changed

+3368
-0
lines changed

.github/workflows/prod.yml

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