Skip to content

Commit 8a5df0c

Browse files
committed
feat: add working docker compose
1 parent 7a20193 commit 8a5df0c

4 files changed

Lines changed: 73 additions & 0 deletions

File tree

collection/Dockerfile.dev

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Dockerfile for docker compose
2+
FROM node:18
3+
4+
RUN npm i -g nx

collection/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# DoCSoc Collection System
2+
3+
This is a Next.js Application that allows us to manage merchandise collections securely. Designed to be ran as a docker container with a Postgres DB.
4+
5+
Once deployed, it allows us to control committee member access, import items from eActivities CSV exports, and mark item as collected.
6+
7+
# Why no `package.json`?
8+
9+
This folder has no package.json as it means we can share the same `package.json` as the rest of the monorepo. This means we can share dependencies like React and scripts across all app, rather than having to maintain multiple `package.json` files and React versions, etc.
10+
11+
Other tools have their own package.jsons as that was how they were originally set up.
12+
13+
# Quick Start
14+
15+
## Local
16+
17+
1. From the root of the repo run `npm install`
18+
2. Copy `.env.local.template` to `.env.local` and fill in the details
19+
3. Run from this dir `npx nx prisma-push` to create the database
20+
4. Run from this dir `npx nx dev` to start the dev server
21+
22+
## Docker
23+
24+
1. Copy `.env.local.template` to `.env.local` and fill in the details
25+
2. From the current dir (`collection`) run `docker compose -f dev.docker-compose.yml up`. This start a dev docker compose instance that has the source code _mounted_ into it: meaning you need not rebuild the docker image every time you make a change!
26+
3. Visit `http://localhost:3000` in your browser and login with the root user you setu in the `.env.local` file
27+
4. To run future DB migrations in docker compose run `docker exec -i $(docker ps -qf "name=docsoc-collection" | head -n1) npx nx prisma-migrate collection --name migration-name`
28+
29+
# Docker
30+
31+
To build the docker image, run `npx nx container collection` from the _root_ of the repo.

collection/dev.docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
services:
2+
docsoc-collection:
3+
image: docsoc/collection-dev
4+
pull_policy: never
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.dev
8+
depends_on:
9+
- docsoc-database
10+
environment:
11+
- NODE_ENV=development
12+
- COLLECTION_DATABASE_URL=postgres://user:pass@docsoc-database:5432/docsoc
13+
env_file: .env.local
14+
ports:
15+
- "3000:3000"
16+
volumes:
17+
- ..:/app
18+
working_dir: /app
19+
command:
20+
- bash
21+
- -c
22+
- ./collection/scripts/compose-entry.sh
23+
24+
docsoc-database:
25+
image: postgres:16
26+
environment:
27+
- POSTGRES_USER=user
28+
- POSTGRES_PASSWORD=pass
29+
- POSTGRES_DB=docsoc
30+
ports:
31+
- "5432:5432"
32+
volumes:
33+
- database-data:/var/lib/postgresql/data
34+
35+
volumes:
36+
database-data:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
npx nx prisma-deploy collection --dev
2+
npx nx run collection:dev

0 commit comments

Comments
 (0)