-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a70fbae
commit f3bfeaa
Showing
9 changed files
with
146 additions
and
10 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.env | ||
.env.dev | ||
dist | ||
node_modules | ||
node_modules | ||
.npm |
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,19 @@ | ||
# Use the official Node.js LTS image | ||
FROM node:20.10.0-bullseye-slim | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/app | ||
|
||
# Copy package.json and package-lock.json to the working directory (better layer caching) | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN --mount=type=cache,target=/usr/src/app/.npm \ | ||
npm set cache /usr/src/app/.npm && \ | ||
npm install | ||
|
||
# Copy all local files to the working directory | ||
COPY . . | ||
|
||
# Command to run the app | ||
CMD ["npm", "run", "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 |
---|---|---|
@@ -1,8 +1,32 @@ | ||
up: | ||
@echo "Stopping docker images (if running...)" | ||
docker-compose down | ||
@echo "Building (when required) and starting docker images..." | ||
docker-compose up --build -d | ||
@echo "Docker images built and started!" | ||
PROD_COMPOSE_FILE=docker-compose.yml | ||
DEV_COMPOSE_FILE=docker-compose-dev.yml | ||
DEBUG_COMPOSE_FILE=docker-compose-debug.yml | ||
TEST_COMPOSE_FILE=docker-compose-test.yml | ||
|
||
### DOCKER COMPOSE COMMANDS | ||
|
||
.PHONY: compose-build | ||
compose-build: | ||
docker compose -f $(DEV_COMPOSE_FILE) build | ||
|
||
.PHONY: compose-up | ||
compose-up: | ||
docker compose -f $(DEV_COMPOSE_FILE) up | ||
|
||
.PHONY: compose-up-build | ||
compose-up-build: | ||
docker compose -f $(DEV_COMPOSE_FILE) up --build | ||
|
||
.PHONY: compose-up-debug-build | ||
compose-up-debug-build: | ||
docker compose -f $(DEV_COMPOSE_FILE) -f $(DEBUG_COMPOSE_FILE) up --build | ||
|
||
.PHONY: compose-down | ||
compose-down: | ||
docker compose -f $(DEV_COMPOSE_FILE) down | ||
|
||
### | ||
|
||
.PHONY: run-tests | ||
run-tests: | ||
docker compose -f $(DEV_COMPOSE_FILE) -f $(TEST_COMPOSE_FILE) run --build api-node |
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,12 @@ | ||
# Overlay configuration to enable debuggers | ||
version: "3.9" | ||
services: | ||
app: | ||
command: | ||
- "npm" | ||
- "run" | ||
- "debug-docker" | ||
ports: | ||
- "5000:5000" | ||
# inspect debug port | ||
- "9229:9229" |
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,41 @@ | ||
version: "3" | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile.dev | ||
ports: | ||
- "5000:5000" | ||
networks: | ||
- backend | ||
depends_on: | ||
- mongo | ||
env_file: | ||
- .env.dev | ||
volumes: | ||
- type: bind | ||
source: . | ||
target: /usr/src/app/ | ||
- type: volume | ||
target: /usr/src/app/node_modules | ||
deploy: | ||
mode: replicated | ||
replicas: 1 | ||
|
||
mongo: | ||
image: mongo:6.0.4 | ||
ports: | ||
- "27018:27017" | ||
networks: | ||
- backend | ||
volumes: | ||
- mongodata:/data/db | ||
|
||
volumes: | ||
mongodata: | ||
driver: local | ||
|
||
networks: | ||
backend: | ||
name: backend |
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 @@ | ||
# Overlay configuration to run tests | ||
version: "3.9" | ||
services: | ||
app: | ||
command: | ||
- "npm" | ||
- "run" | ||
- "test" |
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