-
-
Notifications
You must be signed in to change notification settings - Fork 69
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 #117 from iisisrael/docker-config
Updates dev environment to use docker
- Loading branch information
Showing
6 changed files
with
185 additions
and
20 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 |
---|---|---|
|
@@ -8,4 +8,5 @@ docker-compose.yml | |
dump | ||
.DS_Store | ||
bk | ||
backend/dist | ||
backend/dist | ||
docker/db |
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,39 @@ | ||
name: lotr | ||
services: | ||
mongo: | ||
build: | ||
context: .. | ||
dockerfile: docker/dockerfile | ||
target: lotr_mongo | ||
environment: | ||
MONGO_INITDB_DATABASE: lotr | ||
ports: | ||
- 27017:27017 | ||
restart: on-failure | ||
volumes: | ||
- ./db:/data/db | ||
|
||
backend: | ||
# Using the debian version rather than alpine to support binary execution e.g. bcrypt | ||
image: node:21.2 | ||
command: [ "npm", "run", "dev" ] | ||
depends_on: | ||
- mongo | ||
environment: | ||
DATABASE_URL: "mongodb://mongo:27017/lotr" | ||
ports: | ||
- 3001:3001 | ||
volumes: | ||
- ../backend:/app | ||
working_dir: /app | ||
|
||
frontend: | ||
image: node:21.2-alpine | ||
command: [ "npm", "run", "start" ] | ||
depends_on: | ||
- backend | ||
ports: | ||
- 3000:3000 | ||
volumes: | ||
- ../frontend:/app | ||
working_dir: /app |
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,40 @@ | ||
#################### | ||
### COMMAND LINE ### | ||
#################### | ||
|
||
# Using the debian version rather than alpine, cuz bash and stuff | ||
FROM node:21.2 as lotr_cli | ||
|
||
WORKDIR /app | ||
|
||
COPY ./docker/npm-build.sh . | ||
|
||
RUN chmod +x npm-build.sh | ||
|
||
# Configure the user's id and group id to match the host file system | ||
RUN userdel -r node | ||
|
||
ARG USER_ID | ||
|
||
ARG GROUP_ID | ||
|
||
RUN getent group $GROUP_ID || addgroup --gid $GROUP_ID user | ||
|
||
RUN getent passwd $USER_ID || adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user | ||
|
||
# Set the active user and open the interactive terminal | ||
USER user | ||
|
||
ENTRYPOINT [ "bash" ] | ||
|
||
|
||
|
||
################ | ||
### DATABASE ### | ||
################ | ||
|
||
FROM mongo:7.0-jammy as lotr_mongo | ||
|
||
COPY ./db/bson /data/init | ||
|
||
RUN echo "mongorestore --archive='/data/init'" > /docker-entrypoint-initdb.d/init.sh |
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 @@ | ||
#!/bin/bash | ||
|
||
# this file is copied into the CLI image to automate installing node dependencies | ||
|
||
cd backend | ||
npm install --include=dev | ||
cd ../frontend | ||
npm install --include=dev |
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,14 @@ | ||
# build the command line interface and install node packages | ||
build: | ||
docker build --build-arg "USER_ID=$$(id -u)" --build-arg "GROUP_ID=$$(id -g)" -f ./docker/dockerfile --target lotr_cli -t lotr-cli:latest . | ||
docker run -v ./backend:/app/backend -v ./frontend:/app/frontend --entrypoint /app/npm-build.sh -it --rm --name lotr-cli lotr-cli | ||
|
||
# start and stop the local environment | ||
up: | ||
docker compose -f docker/compose.yml up -d | ||
down: | ||
docker compose -f docker/compose.yml down | ||
|
||
# run the command line interface to manage application dependencies and run tests | ||
cli: | ||
docker run -v ./backend:/app/backend -v ./frontend:/app/frontend -it --rm --name lotr-cli lotr-cli |