-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from helloitsdave/dockerised-be
[backend] feature: Dockerised db + app
- Loading branch information
Showing
12 changed files
with
339 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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,34 @@ | ||
name: Build Backend Docker | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./backend | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Start service in docker | ||
run: | | ||
npm run docker:up | ||
- name: Stop service in docker | ||
run: | | ||
npm run docker:down |
This file contains 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 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,17 @@ | ||
version: "3" | ||
services: | ||
postgres: | ||
image: postgres:13 | ||
environment: | ||
POSTGRES_USER: test | ||
POSTGRES_PASSWORD: test | ||
POSTGRES_DB: test | ||
ports: | ||
- "5432:5432" | ||
app: | ||
build: . | ||
command: ["sh", "-c", "./wait-for-it.sh postgres:5432 -- npx prisma migrate deploy && npm run seed && npm start"] | ||
ports: | ||
- "5001:5001" | ||
environment: | ||
DATABASE_URL: "postgresql://test:test@postgres:5432/test" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,8 @@ | ||
-- CreateTable | ||
CREATE TABLE "Note" ( | ||
"id" SERIAL NOT NULL, | ||
"title" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Note_pkey" PRIMARY KEY ("id") | ||
); |
This file contains 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,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains 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,62 @@ | ||
// prisma/seed.js | ||
|
||
import { PrismaClient } from '@prisma/client'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
const seed = [ | ||
{ | ||
"title": "Meeting Notes", | ||
"content": "Discussed project timelines and goals." | ||
}, | ||
{ | ||
"title": "Shopping List", | ||
"content": "Milk, eggs, bread, and fruits." | ||
}, | ||
{ | ||
"title": "Recipe", | ||
"content": "Ingredients: Chicken, tomatoes, onions, garlic." | ||
}, | ||
{ | ||
"title": "Ideas", | ||
"content": "Brainstorming ideas for the next feature release. 🚀" | ||
}, | ||
{ | ||
"title": "Personal Goals", | ||
"content": "Exercise for 30 minutes daily. Read a book every week." | ||
}, | ||
{ | ||
"title": "Fête d'anniversaire", | ||
"content": "Préparer une surprise pour la fête d'anniversaire." | ||
}, | ||
{ | ||
"title": "日本旅行", | ||
"content": "計画: 東京、京都、大阪を訪れる。" | ||
}, | ||
{ | ||
"title": "Семейный ужин", | ||
"content": "Приготовить вкусный ужин для всей семьи." | ||
}, | ||
{ | ||
"title": "Coding Project", | ||
"content": "Implement new features using React and Express." | ||
} | ||
] | ||
|
||
async function main() { | ||
// Seed data here | ||
await prisma.note.createMany({ | ||
data: seed, | ||
}); | ||
|
||
// Add more data as needed... | ||
} | ||
|
||
main() | ||
.catch((e) => { | ||
console.error(e); | ||
// process.exit(1); | ||
}) | ||
.finally(async () => { | ||
await prisma.$disconnect(); | ||
}); |
Oops, something went wrong.