Skip to content

Commit 52e505e

Browse files
Adding docker and github stuff
1 parent ed9eee3 commit 52e505e

7 files changed

Lines changed: 161 additions & 71 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ jest.config.*
4545

4646
# Database file (will be created in container)
4747
prisma/dev.db
48-
prisma/dev.db-journal
48+
prisma/dev.db-journal

.github/pull_request_template.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!-- IF A SECTION IS NOT APPLICABLE TO YOU, PLEASE DELETE IT!! -->
2+
3+
<!-- Your title should be able to summarize what changes you've made in one sentence. For example: "Exclude staff from the check for follows". For stacked PRs, please indicate clearly in the title where in the stack you are. For example: "[Eatery Refactor][4/5] Converted all files to MVP model" -->
4+
5+
## Overview
6+
7+
<!-- Summarize your changes here. -->
8+
9+
## Changes Made
10+
11+
<!-- Include details of what your changes actually are and how it is intended to work. -->
12+
13+
## Test Coverage
14+
15+
<!-- Describe how you tested this feature. Manual testing and/or unit testing. Please include repro steps and/or how to turn the feature on if applicable. -->
16+
17+
## Next Steps (delete if not applicable)
18+
19+
<!-- If this is part of a multi-PR change, please describe what changes you plan on addressing in future PRs. -->
20+
21+
## Related PRs or Issues (delete if not applicable)
22+
23+
<!-- List related PRs against other branches/repositories. -->
24+
25+
## Screenshots (delete if not applicable)
26+
27+
<!-- This could include of screenshots of the new feature / proof that the changes work. -->
28+
29+
<details>
30+
31+
<summary>Screen Shot Name</summary>
32+
33+
<!-- Insert file link here. Newlines above and below your link are necessary for this to work. -->
34+
35+
</details>

.github/workflows/deploy-dev.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Build & Push and Deploy to dev for eatery-blue-backend
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKER_USERNAME }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
25+
- name: Get SHA
26+
id: vars
27+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: Docker Build & Push
30+
uses: docker/build-push-action@v5
31+
with:
32+
context: ./
33+
file: ./Dockerfile
34+
push: true
35+
tags: cornellappdev/eatery-blue-dev:${{ steps.vars.outputs.sha_short }}
36+
37+
- name: Remote SSH and Deploy
38+
uses: appleboy/ssh-action@v1.0.3
39+
env:
40+
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
41+
with:
42+
host: ${{ secrets.DEV_SERVER_HOST }}
43+
username: ${{ secrets.SERVER_USERNAME }}
44+
key: ${{ secrets.DEV_SERVER_KEY }}
45+
script: |
46+
export IMAGE_TAG=${{ steps.vars.outputs.sha_short }}
47+
cd docker-compose
48+
docker stack rm thestack
49+
sleep 20s
50+
docker stack deploy -c docker-compose.yml thestack
51+
yes | docker system prune -a

.github/workflows/deploy-prod.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Docker Build & Push and Deploy to prod for eatery-blue-backend
2+
3+
on:
4+
push:
5+
branches: [release]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
19+
- name: Login to DockerHub
20+
uses: docker/login-action@v3
21+
with:
22+
username: ${{ secrets.DOCKER_USERNAME }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
25+
- name: Get SHA
26+
id: vars
27+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: Docker Build & Push
30+
uses: docker/build-push-action@v5
31+
with:
32+
context: ./
33+
file: ./Dockerfile
34+
push: true
35+
tags: cornellappdev/eatery-blue:${{ steps.vars.outputs.sha_short }}
36+
37+
- name: Remote SSH and Deploy
38+
uses: appleboy/ssh-action@v1.0.3
39+
env:
40+
IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
41+
with:
42+
host: ${{ secrets.PROD_SERVER_HOST }}
43+
username: ${{ secrets.SERVER_USERNAME }}
44+
key: ${{ secrets.PROD_SERVER_KEY }}
45+
script: |
46+
export IMAGE_TAG=${{ steps.vars.outputs.sha_short }}
47+
cd docker-compose
48+
docker stack rm thestack
49+
sleep 20s
50+
docker stack deploy -c docker-compose.yml thestack
51+
yes | docker system prune -a

.github/workflows/deploy-production.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/deploy-staging.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

docker-compose.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
app:
3+
image: cornellappdev/eatery-blue:${IMAGE_TAG}
4+
volumes:
5+
- ./firebase-service-account.json:/app/firebase-service-account.json:ro
6+
env_file: .env
7+
networks:
8+
- eatery-network
9+
ports:
10+
- "80:8000"
11+
depends_on:
12+
- scraper
13+
14+
scraper:
15+
image: cornellappdev/eatery-blue:${IMAGE_TAG}
16+
env_file: .env
17+
networks:
18+
- eatery-network
19+
command: ["sh", "-c", "npx prisma migrate deploy && npm run scrape:scheduled"]
20+
21+
networks:
22+
eatery-network:
23+
driver: bridge

0 commit comments

Comments
 (0)