-
Notifications
You must be signed in to change notification settings - Fork 1
feat: added docker-compose and nginx configs #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50577c5
Configure containerization and deployment settings
divyansh-v15-06 24b19e7
Update docker-compose exposed host ports to avoid server conflicts
divyansh-v15-06 5f93c57
Add auto-seeding for default admin users
divyansh-v15-06 99d5d80
Update seedUsers to seed verified Faculty, Warden, and Centrehead
divyansh-v15-06 e4a99d6
Configure deployment workflow and make seeding conditional on SEED_DB
divyansh-v15-06 fa38fe8
Update deployment workflow to run tests on pull requests
divyansh-v15-06 2a53b96
Test automated CI/CD deployment pipeline
divyansh-v15-06 8c5525c
Switch CI/CD auth to SSH_PASSWORD
divyansh-v15-06 e79ab90
Test automated CI/CD deployment with password auth
divyansh-v15-06 2fcfd8b
Remove sudo prefix from docker compose command in CI/CD
divyansh-v15-06 3175814
Use sg docker -c for compose command
divyansh-v15-06 7ef0048
Refactor backend to load environment from .env file directly
divyansh-v15-06 ef79563
Use sudo docker compose in deploy.yml
divyansh-v15-06 3ac4d30
Remove seeding logic from database config for production
divyansh-v15-06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| name: Deploy to College Server | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true | ||
|
|
||
| - name: Download dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Run tests | ||
| run: go test ./test/... -v -count=1 | ||
|
|
||
| deploy: | ||
| name: Deploy via SSH | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
|
|
||
| steps: | ||
| - name: Deploy to Server via SSH | ||
| uses: appleboy/ssh-action@v1.0.3 | ||
| with: | ||
| host: ${{ secrets.SSH_HOST }} | ||
| username: ${{ secrets.SSH_USERNAME }} | ||
| key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
| port: 22 | ||
| script: | | ||
| cd ~/cms-webb | ||
| git pull origin main | ||
| sudo docker compose up -d --build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Stage 1: Build the Go application | ||
| FROM golang:1.26-alpine AS builder | ||
| WORKDIR /app | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
| COPY . . | ||
| RUN CGO_ENABLED=0 GOOS=linux go build -o main . | ||
|
|
||
| # Stage 2: Final minimal image | ||
| FROM alpine:latest | ||
| RUN apk --no-cache add ca-certificates | ||
| WORKDIR /root/ | ||
| COPY --from=builder /app/main . | ||
| EXPOSE 8080 | ||
| CMD ["./main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Stage 1: Build the React application | ||
| FROM node:20-alpine AS builder | ||
| WORKDIR /app | ||
| COPY package.json package-lock.json ./ | ||
| RUN npm ci | ||
| COPY . . | ||
| RUN npm run build | ||
|
|
||
| # Stage 2: Serve the static files using Nginx | ||
| FROM nginx:alpine | ||
| COPY --from=builder /app/dist /usr/share/nginx/html | ||
| COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
| EXPOSE 80 | ||
| CMD ["nginx", "-g", "daemon off;"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| server { | ||
| listen 80; | ||
| server_name localhost; | ||
|
|
||
| location / { | ||
| root /usr/share/nginx/html; | ||
| index index.html index.htm; | ||
| try_files $uri $uri/ /index.html; | ||
| } | ||
|
|
||
| # Proxy API requests to the Go backend | ||
| location /api/ { | ||
| proxy_pass http://backend:8080; | ||
| proxy_http_version 1.1; | ||
| proxy_set_header Upgrade $http_upgrade; | ||
| proxy_set_header Connection 'upgrade'; | ||
| proxy_set_header Host $host; | ||
| proxy_cache_bypass $http_upgrade; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| db: | ||
| image: postgres:15-alpine | ||
| container_name: cms-db | ||
| restart: always | ||
| environment: | ||
| POSTGRES_USER: ${DB_USER:-postgres} | ||
| POSTGRES_PASSWORD: ${DB_PASS:-postgres} | ||
| POSTGRES_DB: ${DB_NAME:-cms} | ||
| ports: | ||
| - "5433:5432" | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data | ||
|
|
||
| backend: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| container_name: cms-backend | ||
| restart: always | ||
| depends_on: | ||
| - db | ||
| environment: | ||
| DB_HOST: db | ||
| DB_PORT: 5432 | ||
| DB_USER: ${DB_USER:-postgres} | ||
| DB_PASS: ${DB_PASS:-postgres} | ||
| DB_NAME: ${DB_NAME:-cms} | ||
| JWT_SECRET: ${JWT_SECRET} | ||
| APP_PASSWORD: ${APP_PASSWORD} | ||
| SENDER_EMAIL: ${SENDER_EMAIL} | ||
| FRONTEND_URL: ${FRONTEND_URL:-http://localhost} | ||
| COOKIE_DOMAIN: ${COOKIE_DOMAIN:-} | ||
| ports: | ||
| - "8082:8080" | ||
|
|
||
| frontend: | ||
| build: | ||
| context: ./app | ||
| dockerfile: Dockerfile | ||
| container_name: cms-frontend | ||
| restart: always | ||
| ports: | ||
| - "8083:80" | ||
| depends_on: | ||
| - backend | ||
|
|
||
| volumes: | ||
| postgres_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.