Skip to content
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

improved deploy and docker #59

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
name: Deploy to EC2

on:
pull_request:
types: [closed]
workflow_dispatch:
inputs:
deploy:
description: 'Deploy to EC2?'
deployment_type:
description: 'Deploy to EC2'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
- 'full-rebuild'
- 'app-only'
- 'none'
default: 'none'

jobs:
deploy:
runs-on: ubuntu-latest
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.deployment_type != 'none') ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'deploy'))
steps:
- name: Deploy to EC2
Expand All @@ -29,7 +29,13 @@ jobs:
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/geoChat/
docker compose down
docker system prune -a -f --filter "until=24h"
git pull origin main
docker compose up -d --build
if [[ "${{ github.event.inputs.deployment_type }}" == "full-rebuild" ]]; then
docker compose down
git pull origin main
docker compose up -d --build
docker system prune -a -f --volumes=false --filter "until=24h"
else
git pull origin main
docker compose up -d --build app
docker image prune -f
fi
2 changes: 1 addition & 1 deletion client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HelmetProvider } from "react-helmet-async";
import Countdown from "./pages/Countdown";

function App() {
const launchDate = new Date(2024, 9, 28, 12, 0, 0);
const launchDate = new Date(2024, 8, 28, 12, 0, 0);
const [isLaunched, setIsLaunched] = useState(false);

return (
Expand Down
24 changes: 15 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
services:
app:
build: .
restart: unless-stopped
deploy:
replicas: 1
update_config:
order: start-first
failure_action: rollback
environment:
- PORT=3000
- MONGO_URL=${MONGO_URL}
Expand All @@ -11,16 +17,19 @@ services:
depends_on:
mongodb:
condition: service_healthy
https-portal:
condition: service_started
healthcheck:
test: [ "CMD", "curl", "-f", "http://localhost:3000" ]
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s

mongodb:
image: mongo:latest
command: [ "--replSet", "rs0", "--bind_ip_all", "--port", "27017" ]
command: ["--replSet", "rs0", "--bind_ip_all", "--port", "27017"]
restart: unless-stopped
healthcheck:
test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongodb:27017'}]}) }" | mongosh --quiet
interval: 10s
Expand All @@ -33,25 +42,22 @@ services:

https-portal:
image: steveltn/https-portal:1
restart: unless-stopped
ports:
- '80:80'
- '443:443'
- "80:80"
- "443:443"
environment:
DOMAINS: 'geochat.live -> http://app:3000, www.geochat.live => https://geochat.live'
STAGE: 'production'
WEBSOCKET: 'true'
volumes:
- https-portal-data:/var/lib/https-portal
depends_on:
app:
condition: service_healthy

volumes:
mongodb_data:
mongodb_config:
https-portal-data:


networks:
default:
name: geochat-network
name: geochat-network