Merge pull request #188 from bluewave-labs/feat/full-app-docker
Full application docker compose set up, resolves #187
This commit is contained in:
11 files changed
+93
-53
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
Client/node_modules/
|
||||||
|
Server/node_modules/
|
||||||
|
*.env
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
*.sh
|
||||||
|
!build_images.sh
|
||||||
|
mongo/data/*
|
||||||
|
redis/data/*
|
||||||
|
*.env
|
||||||
Regular → Executable
+7
-3
@@ -4,15 +4,19 @@
|
|||||||
# Change directory to root Server directory for correct Docker Context
|
# Change directory to root Server directory for correct Docker Context
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
#Client
|
||||||
|
client="./Docker/client.Dockerfile"
|
||||||
|
|
||||||
# MongoDB
|
# MongoDB
|
||||||
mongoDB="./docker/mongoDB.Dockerfile"
|
mongoDB="./Docker/mongoDB.Dockerfile"
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
redis="./docker/redis.Dockerfile"
|
redis="./Docker/redis.Dockerfile"
|
||||||
|
|
||||||
# Server
|
# Server
|
||||||
server="./docker/server.Dockerfile"
|
server="./Docker/server.Dockerfile"
|
||||||
|
|
||||||
|
docker build -f $client -t uptime_client .
|
||||||
docker build -f $mongoDB -t uptime_database_mongo .
|
docker build -f $mongoDB -t uptime_database_mongo .
|
||||||
docker build -f $redis -t uptime_redis .
|
docker build -f $redis -t uptime_redis .
|
||||||
docker build -f $server -t uptime_server .
|
docker build -f $server -t uptime_server .
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
FROM node:20
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ./Client/package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY ./Client .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
RUN npm install -g serve
|
||||||
|
|
||||||
|
CMD ["serve","-s", "dist", "-l", "5173"]
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
@@ -1,11 +1,19 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
|
client:
|
||||||
|
image: uptime_client:latest
|
||||||
|
ports:
|
||||||
|
- "5173:5173"
|
||||||
|
env_file:
|
||||||
|
- client.env
|
||||||
|
depends_on:
|
||||||
|
- server
|
||||||
server:
|
server:
|
||||||
image: uptime_server:latest
|
image: uptime_server:latest
|
||||||
ports:
|
ports:
|
||||||
- "5000:5000"
|
- "5000:5000"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- server.env
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
- mongodb
|
- mongodb
|
||||||
File renamed without changes.
File renamed without changes.
@@ -2,11 +2,11 @@ FROM node:20
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ../../package*.json ./
|
COPY ./Server/package*.json ./
|
||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
COPY ../../ ./
|
COPY ./Server/ ./
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
@@ -27,18 +27,17 @@ You can see the designs [here](https://www.figma.com/design/RPSfaw66HjzSwzntKcgD
|
|||||||
|
|
||||||
- Clone this repository to your local machine
|
- Clone this repository to your local machine
|
||||||
|
|
||||||
|
1. [Docker Quickstart](#docker-compose)
|
||||||
1. [Installation (Client)](#client)
|
1. [Installation (Client)](#client)
|
||||||
2. [Configuration(Client)](#config-client)
|
1. [Configuration(Client)](#config-client)
|
||||||
- [Environment](#env-vars-client)
|
- [Environment](#env-vars-client)
|
||||||
3. [Getting Started (Server)](#server)
|
1. [Getting Started (Server)](#server)
|
||||||
- [Docker Compose Quickstart](#docker-quickstart)
|
- [Install Server](#install-server)
|
||||||
- [Manual Installation](#manual-install)
|
- [Environment](#env-vars-server)
|
||||||
- [Install Server](#install-server)
|
- [Database](#databases)
|
||||||
- [Environment](#env-vars-server)
|
- [(Optional) Dockerised Databases](#optional-docker-databases)
|
||||||
- [Database](#databases)
|
- [Start Server](#start-server)
|
||||||
- [(Optional) Dockerised Databases](#optional-docker-databases)
|
1. [Endpoints](#endpoints)
|
||||||
- [Start Server](#start-server)
|
|
||||||
4. [Endpoints](#endpoints)
|
|
||||||
###### Auth
|
###### Auth
|
||||||
- <code>POST</code> [/api/v1/auth/register](#post-register)
|
- <code>POST</code> [/api/v1/auth/register](#post-register)
|
||||||
- <code>POST</code> [/api/v1/auth/login](#post-login)
|
- <code>POST</code> [/api/v1/auth/login](#post-login)
|
||||||
@@ -64,11 +63,45 @@ You can see the designs [here](https://www.figma.com/design/RPSfaw66HjzSwzntKcgD
|
|||||||
- <code>GET</code> [/api/v1/alerts/{alertId}](#get-alert-alert-id)
|
- <code>GET</code> [/api/v1/alerts/{alertId}](#get-alert-alert-id)
|
||||||
- <code>POST</code> [/api/v1/alerts/edit/{alertId}](#edit-alert)
|
- <code>POST</code> [/api/v1/alerts/edit/{alertId}](#edit-alert)
|
||||||
- <code>POST</code> [/api/v1/alerts/delete/{alertId}](#delete-alert)
|
- <code>POST</code> [/api/v1/alerts/delete/{alertId}](#delete-alert)
|
||||||
5. [Error Handling](#error-handling)
|
1. [Error Handling](#error-handling)
|
||||||
6. [Contributors](#contributors)
|
1. [Contributors](#contributors)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### Docker Quick Start
|
||||||
|
|
||||||
|
#### <u>Docker Quickstart</u> <a id="docker-quickstart"></a>
|
||||||
|
|
||||||
|
The fastest way to start the application is to use our Dockerfiles and [Docker Compose](https://docs.docker.com/compose/).
|
||||||
|
|
||||||
|
To get the application up and running you need to:
|
||||||
|
|
||||||
|
1. In the `Docker` directory run the build script `build_images.sh` to build docker images for the client, server, Redis database, and MongoDB database.
|
||||||
|
2. In the `Docker` directory, create a `server.env` file with the [requried environtmental variables](#env-vars-server) for the server. Sample file:
|
||||||
|
|
||||||
|
```
|
||||||
|
CLIENT_HOST="http://localhost:5173"
|
||||||
|
JWT_SECRET="my_secret"
|
||||||
|
DB_TYPE="MongoDB"
|
||||||
|
DB_CONNECTION_STRING="mongodb://mongodb:27017/uptime_db"
|
||||||
|
REDIS_HOST="redis"
|
||||||
|
REDIS_PORT=6379
|
||||||
|
SYSTEM_EMAIL_ADDRESS="<email>"
|
||||||
|
SENDGRID_API_KEY="<api_key>"
|
||||||
|
LOGIN_PAGE_URL="<login_page"
|
||||||
|
```
|
||||||
|
|
||||||
|
3. In the `Docker` directory, create a `client.env` file with the [required environtmental variables](#env-vars-cllient) for the client. Sample file:
|
||||||
|
|
||||||
|
```
|
||||||
|
VITE_APP_API_BASE_URL="http://localhost:5000/api/v1"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. In the `Docker` directory run `docker compose up` to run the `docker-compose.yaml` file and start all four images.
|
||||||
|
|
||||||
|
That's it, the application is ready to use on port 5173.
|
||||||
|
<br/>
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
|
|
||||||
#### <u>Installation</u>
|
#### <u>Installation</u>
|
||||||
@@ -96,32 +129,6 @@ You can see the designs [here](https://www.figma.com/design/RPSfaw66HjzSwzntKcgD
|
|||||||
|
|
||||||
### Getting Started (Server) <a id="server"></a>
|
### Getting Started (Server) <a id="server"></a>
|
||||||
|
|
||||||
#### <u>Docker Quickstart</u> <a id="docker-quickstart"></a>
|
|
||||||
|
|
||||||
The fastest way to start the server is to use our Dockerfiles and [Docker Compose](https://docs.docker.com/compose/).
|
|
||||||
|
|
||||||
To get the server up and running you need to:
|
|
||||||
|
|
||||||
1. In the `Server/docker` directory run the build script `build_images.sh` to build docker images for the server, Redis database, and MongoDB database.
|
|
||||||
2. In the `Server/docker` directory, create a `.env` file with the [requried environtmental variables](#env-vars-server). Sample file:
|
|
||||||
|
|
||||||
```
|
|
||||||
CLIENT_HOST="http://localhost:5173"
|
|
||||||
JWT_SECRET="my_secret"
|
|
||||||
DB_TYPE="MongoDB"
|
|
||||||
DB_CONNECTION_STRING="mongodb://mongodb:27017/uptime_db"
|
|
||||||
REDIS_HOST="redis"
|
|
||||||
REDIS_PORT=6379
|
|
||||||
SYSTEM_EMAIL_ADDRESS="<email>"
|
|
||||||
SENDGRID_API_KEY="<api_key>"
|
|
||||||
LOGIN_PAGE_URL="<login_page"
|
|
||||||
```
|
|
||||||
|
|
||||||
3. In the `Server/docker` directory run `docker compose up` to run the `docker-compose.yaml` file and start all three images.
|
|
||||||
|
|
||||||
That's it, the server is ready to use.
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
#### <u>Manual Install</u> <a id="manual-install"></a>
|
#### <u>Manual Install</u> <a id="manual-install"></a>
|
||||||
|
|
||||||
##### Install Server <a id="install-server"></a>
|
##### Install Server <a id="install-server"></a>
|
||||||
@@ -162,15 +169,15 @@ You may use the included Dockerfiles to spin up databases quickly if you wish.
|
|||||||
|
|
||||||
###### (Optional) Dockerised Databases <a id="optional-docker-databases"></a>
|
###### (Optional) Dockerised Databases <a id="optional-docker-databases"></a>
|
||||||
|
|
||||||
Dockerfiles for the server and databases are located in the `./Server/docker` directory
|
Dockerfiles for the server and databases are located in the `Docker` directory
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><b>MongoDB Image</b></summary>
|
<summary><b>MongoDB Image</b></summary>
|
||||||
Location: `./Server/docker/mongoDB.Dockerfile`
|
Location: `./Server/docker/mongoDB.Dockerfile`
|
||||||
|
|
||||||
The `./Server/docker/mongo/data` directory should be mounted to the MongoDB container in order to persist data.
|
The `Docker/mongo/data` directory should be mounted to the MongoDB container in order to persist data.
|
||||||
|
|
||||||
From the `Server/docker` directory run
|
From the `Docker` directory run
|
||||||
|
|
||||||
1. Build the image: `docker build -f mongoDB.Dockerfile -t uptime_database_mongo .`
|
1. Build the image: `docker build -f mongoDB.Dockerfile -t uptime_database_mongo .`
|
||||||
2. Run the docker image: `docker run -d -p 27017:27017 -v $(pwd)/mongo/data:/data/db --name uptime_database_mongo uptime_database_mongo`
|
2. Run the docker image: `docker run -d -p 27017:27017 -v $(pwd)/mongo/data:/data/db --name uptime_database_mongo uptime_database_mongo`
|
||||||
@@ -180,9 +187,9 @@ From the `Server/docker` directory run
|
|||||||
<summary><b>Redis Image</b></summary>
|
<summary><b>Redis Image</b></summary>
|
||||||
Location `./Server/docker/redislDockerfile`
|
Location `./Server/docker/redislDockerfile`
|
||||||
|
|
||||||
the `./Server/docker/redis/data` directory should be mounted to the Redis container in order to persist data.
|
the `Docker/redis/data` directory should be mounted to the Redis container in order to persist data.
|
||||||
|
|
||||||
From the `Server/docker` directory run
|
From the `Docker` directory run
|
||||||
|
|
||||||
1. Build the image: `docker build -f redis.Dockerfile -t uptime_redis .`
|
1. Build the image: `docker build -f redis.Dockerfile -t uptime_redis .`
|
||||||
2. Run the image: `docker run -d -p 6379:6379 -v $(pwd)/redis/data:/data --name uptime_redis uptime_redis`
|
2. Run the image: `docker run -d -p 6379:6379 -v $(pwd)/redis/data:/data --name uptime_redis uptime_redis`
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
./docker
|
|
||||||
@@ -2,6 +2,3 @@ node_modules
|
|||||||
.env
|
.env
|
||||||
*.log
|
*.log
|
||||||
*.sh
|
*.sh
|
||||||
docker/mongo/data/*
|
|
||||||
docker/redis/data/*
|
|
||||||
!docker/build_images.sh
|
|
||||||
Reference in new issue
Block a user