Skip to content

Commit

Permalink
Add job to deploy frontend to droplet instead of netlify
Browse files Browse the repository at this point in the history
  • Loading branch information
Aadesh-Baral committed Mar 20, 2023
1 parent 9990fbf commit 22b3477
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
26 changes: 22 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

jobs:
build-and-deploy:
backend-deploy:
# Use the Docker executor to run Docker commands
docker:
- image: docker:20.10.12
Expand All @@ -19,20 +19,38 @@ jobs:
&& docker build -t localizer-backend:latest ."
# SSH into the DigitalOcean droplet and deploy the app using Docker Compose
- run:
name: Deploy app
name: Deploy backend
command: |
ssh -oStrictHostKeyChecking=no -v ${SSH_USER}@${SERVER_IP} "cd OSMLocalizer \
&& docker-compose down \
&& docker-compose up -d"
frontend-deploy:
docker:
- image: cimg/node:18.15.0
steps:
- checkout
- run:
name: Create build
command: |
cd frontend \
&& npm install \
&& npm run build
- run:
name: Deploy frontend
command: |
scp -oStrictHostKeyChecking=no -r frontend/build ${SSH_USER}@${SERVER_IP}:/home/${SSH_USER}/OSMLocalizer/frontend
# Run jobs from above in configurable sequences called workflows
workflows:
version: 2
# Workflow name
build-deploy:
jobs:
- build-and-deploy:
- backend-deploy:
filters:
branches:
only: master
- frontend-deploy:
filters:
branches:
only: master
2 changes: 2 additions & 0 deletions backend/models/sql/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ def get_nearby(feature_id, challenge_id):
).fetchall()
if nearby:
feature = Feature.get_by_id(nearby[0][0], challenge_id)
else:
raise NotFound("NO_FEATURES_TO_LOCALIZE")
return feature
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"scripts": {
"preparation": "bash -c \"if (test -a ../localizer.env); then grep -hs ^ ../localizer.env .env.expand > .env; else cp .env.expand .env; fi\"",
"start": "npm run preparation && react-scripts start",
"build": "react-scripts build",
"build": "npm run preparation && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint --ext .js,.jsx,.ts,.tsx --fix src/",
Expand Down

0 comments on commit 22b3477

Please sign in to comment.