-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Prudhvi Godithi <[email protected]>
- Loading branch information
1 parent
f194866
commit 883201f
Showing
6 changed files
with
118 additions
and
4 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,5 @@ | ||
FROM node:20.17.0 | ||
WORKDIR /usr/app | ||
COPY ../package*.json ./ | ||
RUN npm cache clean --force | ||
COPY ../ . |
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,88 @@ | ||
# GitHub Automation App Setup with Docker | ||
|
||
This GitHub Automation App uses Docker and Docker Compose to build and run a Node.js code with configurable resource and operation settings. Multiple services can be run simultaneously using different configurations. | ||
|
||
## Prerequisites | ||
|
||
Make sure the following installed on the system: | ||
|
||
- Docker: [Get Docker](https://docs.docker.com/get-docker/) | ||
- Docker Compose: [Get Docker Compose](https://docs.docker.com/compose/install/) | ||
|
||
## Project Structure | ||
|
||
```bash | ||
. | ||
├── configs/ | ||
│ ├── operations/ | ||
│ │ ├── github-merged-pulls-monitor.yml | ||
│ │ └── github-workflow-runs-monitor.yml | ||
│ └── resources/ | ||
│ └── sample-resource.yml | ||
├── docker/ | ||
│ ├── Dockerfile | ||
│ └── docker-compose.yml | ||
├── package.json | ||
└── src/ | ||
└── app.js | ||
``` | ||
|
||
## Docker Setup | ||
|
||
The `docker-compose.yml` is configured to use a Node.js image and to run the app. This mounts the project directory to the container for live reloading. | ||
|
||
### Dockerfile | ||
|
||
The `Dockerfile` is used to create a Docker image for the app: | ||
|
||
``` | ||
FROM node:20.17.0 | ||
WORKDIR /usr/app | ||
COPY ../package*.json ./ | ||
RUN npm cache clean --force | ||
COPY ../ . | ||
``` | ||
|
||
### Docker Compose File | ||
|
||
The `docker-compose.yml` file sets up a service (automation-app) to run the app: | ||
|
||
``` | ||
services: | ||
automation-app: | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
npm install | ||
npm start | ||
environment: | ||
- RESOURCE_CONFIG=configs/resources/sample-resource.yml | ||
- OPERATION_CONFIG=${OPERATION_CONFIG} | ||
volumes: | ||
- ../:/usr/app/ | ||
- /usr/app/node_modules | ||
ports: | ||
- "${PORT}:3000" | ||
``` | ||
|
||
### Running the Services | ||
|
||
This allows to run multiple instances of the service with different configurations and ports. | ||
|
||
#### This will run the service on port 8080 with the github-merged-pulls-monitor.yml configuration. | ||
|
||
```bash | ||
PORT=8080 OPERATION_CONFIG=configs/operations/github-merged-pulls-monitor.yml docker-compose -p automation-app-1 up -d | ||
``` | ||
|
||
#### This will run the second service on port 8081 with the github-workflow-runs-monitor.yml configuration. | ||
|
||
``` | ||
PORT=8081 OPERATION_CONFIG=configs/operations/github-workflow-runs-monitor.yml docker-compose -p automation-app-2 up -d | ||
``` |
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 @@ | ||
services: | ||
web: | ||
build: | ||
context: ../ | ||
dockerfile: docker/Dockerfile | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
npm install | ||
npm start | ||
environment: | ||
- RESOURCE_CONFIG=configs/resources/sample-resource.yml | ||
- OPERATION_CONFIG=${OPERATION_CONFIG} | ||
volumes: | ||
- ../:/usr/app/ | ||
- /usr/app/node_modules | ||
ports: | ||
- '${PORT}:3000' |
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
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