Skip to content

Commit b19df00

Browse files
committed
what
0 parents  commit b19df00

File tree

82 files changed

+15002
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+15002
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Git and Docker config
2+
.git
3+
.gitignore
4+
.dockerignore
5+
Dockerfile
6+
7+
# Node.js dependencies
8+
# These should be installed inside the container, not copied from your host
9+
node_modules
10+
frontend/node_modules
11+
12+
# Build artifacts
13+
# These are generated inside the container
14+
dist
15+
build
16+
frontend/dist
17+
backend/target
18+
19+
# IDE and OS files
20+
.vscode
21+
.idea
22+
*.DS_Store
23+
24+
# Log files
25+
npm-debug.log

.env.template

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
GOOGLE_CLIENT_ID=client_id.apps.googleusercontent.com
2+
SIGNING_SECRET=your-signing-secret
3+
EXPIRATION_TIME_SECONDS="86400"
4+
FILE_SIZE_LIMIT="50"
5+
PORT=8085
6+
VITE_API_BASE_URL=http://localhost:8085
7+
FRONTEND_BUILD_DIR=../frontend/dist/
8+
9+
DB_NAME=
10+
DB_HOST=
11+
DB_PORT=
12+
DB_USER=
13+
DB_PASSWORD=
14+
15+
UPLOADED_NOTES_PATH=notes/uploaded
16+
PREVIEWS_PATH=previews/uploaded
17+
LOG_LOCATION=/app/log
18+
19+
# Static Files Configuration
20+
# Axum can serve static files directly from the filesystem if configured.
21+
# To use metakgp/odins-vault in production, you need to set the following environment variables.
22+
STATIC_FILES_URL=http://localhost:8085
23+
STATIC_FILE_STORAGE_LOCATION=/home/exempl4r/static
24+
# /app/static_files for production Docker container
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deploy to Github Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "frontend/**"
9+
- ".github/workflows/deploy-gh-pages.yaml"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # This is the key line
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 22.2.0
25+
26+
- name: Install dependencies
27+
run: |
28+
cd frontend
29+
npm install
30+
31+
- name: Build the application
32+
run: |
33+
cd frontend
34+
npm run build
35+
36+
- name: Deploy
37+
uses: JamesIves/github-pages-deploy-action@v4
38+
with:
39+
folder: ./frontend/dist

.github/workflows/deploy.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Continuous Deployment Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
paths:
8+
- "backend/**"
9+
- ".github/workflows/deploy.yaml"
10+
11+
jobs:
12+
dockerhub:
13+
name: Publish Docker Image(s) to Dockerhub
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v3
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
31+
32+
- name: Cache Docker layers for CFMN Backend
33+
uses: actions/cache@v3
34+
with:
35+
path: /tmp/.buildx-cache-cfmn-backend
36+
key: ${{ runner.os }}-buildx-cfmn-backend-${{ github.sha }}
37+
restore-keys: |
38+
${{ runner.os }}-buildx-cfmn-backend-
39+
40+
- name: Build & Push cfmn Backend
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cfmn-backend:latest
46+
build-args: |
47+
VITE_GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}
48+
cache-from: type=local,src=/tmp/.buildx-cache-cfmn-backend
49+
cache-to: type=local,dest=/tmp/.buildx-cache-cfmn-backend-new,mode=max
50+
51+
- name: Move cfmn cache
52+
run: |
53+
rm -rf /tmp/.buildx-cache-cfmn-backend
54+
mv /tmp/.buildx-cache-cfmn-backend-new /tmp/.buildx-cache-cfmn-backend
55+
56+
push:
57+
name: Push Code Stage
58+
needs: dockerhub
59+
runs-on: ubuntu-latest
60+
61+
steps:
62+
- name: Sync local repo with remote repo
63+
uses: appleboy/ssh-action@master
64+
env:
65+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
66+
with:
67+
host: ${{ secrets.SSH_HOSTNAME }}
68+
username: ${{ secrets.SSH_USERNAME }}
69+
key: ${{ secrets.SSH_PRIVATE_KEY }}
70+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
71+
envs: PROJECT_DIR
72+
script: |
73+
cd "${PROJECT_DIR}"
74+
sudo git fetch origin
75+
sudo git reset --hard origin/main
76+
77+
pull:
78+
name: Pull Image Stage
79+
needs: push
80+
runs-on: ubuntu-latest
81+
82+
steps:
83+
- name: Pull the latest images(s)
84+
uses: appleboy/ssh-action@master
85+
env:
86+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
87+
with:
88+
host: ${{ secrets.SSH_HOSTNAME }}
89+
username: ${{ secrets.SSH_USERNAME }}
90+
key: ${{ secrets.SSH_PRIVATE_KEY }}
91+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
92+
envs: PROJECT_DIR
93+
script_stop: true
94+
script: |
95+
cd "${PROJECT_DIR}"
96+
sudo docker-compose pull
97+
98+
deploy:
99+
name: Deploy Stage
100+
needs: pull
101+
runs-on: ubuntu-latest
102+
103+
steps:
104+
- name: Deploy the latest build(s)
105+
uses: appleboy/ssh-action@master
106+
env:
107+
PROJECT_DIR: ${{ secrets.PROJECT_DIR }}
108+
with:
109+
host: ${{ secrets.SSH_HOSTNAME }}
110+
username: ${{ secrets.SSH_USERNAME }}
111+
key: ${{ secrets.SSH_PRIVATE_KEY }}
112+
passphrase: ${{ secrets.SSH_PRIVATE_KEY_PASSPHRASE }}
113+
envs: PROJECT_DIR
114+
script: |
115+
cd "${PROJECT_DIR}"
116+
sudo docker-compose down
117+
sudo docker-compose --profile prod up -d

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target/
2+
.idea
3+
.env
4+
.log
5+
*.env

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM rust:slim-bullseye AS builder
2+
3+
# Set the working directory
4+
WORKDIR /app
5+
6+
# Install dependencies
7+
RUN apt-get update
8+
RUN apt-get install -y build-essential musl-dev musl-tools pkgconf
9+
10+
# Copy dependency files
11+
COPY backend/Cargo.toml backend/Cargo.lock ./
12+
13+
# Copy source code
14+
COPY backend/src ./src
15+
COPY metaploy ./metaploy
16+
COPY backend/.sqlx ./.sqlx
17+
COPY backend/migrations ./migrations
18+
19+
# For static build
20+
RUN rustup target add x86_64-unknown-linux-musl
21+
RUN cargo build --target=x86_64-unknown-linux-musl --release
22+
23+
FROM alpine:latest AS app
24+
25+
# Install runtime dependencies correctly with apk
26+
RUN apk add --no-cache \
27+
ca-certificates \
28+
tzdata \
29+
bash \
30+
poppler-utils \
31+
nginx
32+
33+
ENV TZ="Asia/Kolkata"
34+
35+
WORKDIR /app
36+
37+
# Copy metaploy files
38+
COPY metaploy ./
39+
40+
# Make postinstall script executable
41+
RUN chmod +x ./postinstall.sh
42+
43+
EXPOSE 8085
44+
45+
# Copy frontend build from the previous stage
46+
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/backend .
47+
48+
CMD ["./postinstall.sh", "./backend"]

0 commit comments

Comments
 (0)