Merge pull request #822 from bluewave-labs/feat/mongo-security
Add env files, update config
This commit is contained in:
4 files changed
+33
-5
No files matched your search
@@ -33,8 +33,11 @@ services:
|
|||||||
- ./redis/data:/data
|
- ./redis/data:/data
|
||||||
mongodb:
|
mongodb:
|
||||||
image: uptime_database_mongo:latest
|
image: uptime_database_mongo:latest
|
||||||
command: ["mongod", "--quiet"]
|
command: ["mongod", "--quiet", "--auth"]
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- ./mongo/data:/data/db
|
- ./mongo/data:/data/db
|
||||||
|
- ./mongo/init/create_users.js:/docker-entrypoint-initdb.d/create_users.js
|
||||||
|
env_file:
|
||||||
|
- mongo.env
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
var username = process.env.USERNAME_ENV_VAR;
|
||||||
|
var password = process.env.PASSWORD_ENV_VAR;
|
||||||
|
|
||||||
|
db = db.getSiblingDB("uptime_db");
|
||||||
|
|
||||||
|
db.createUser({
|
||||||
|
user: username,
|
||||||
|
pwd: password,
|
||||||
|
roles: [
|
||||||
|
{
|
||||||
|
role: "readWrite",
|
||||||
|
db: "uptime_db",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
print("User uptime_user created successfully");
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
FROM mongo
|
FROM mongo
|
||||||
EXPOSE 27017
|
EXPOSE 27017
|
||||||
|
CMD ["mongod"]
|
||||||
@@ -170,13 +170,21 @@ The fastest way to start the application is to use our Dockerfiles and [Docker C
|
|||||||
To get the application up and running you need to:
|
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.
|
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:
|
|
||||||
|
2. In the `Dokcer` directory create a `mongo.env` file with a username and password:
|
||||||
|
|
||||||
|
```
|
||||||
|
USERNAME_ENV_VAR=user
|
||||||
|
PASSWORD_ENV_VAR=password
|
||||||
|
```
|
||||||
|
|
||||||
|
3. 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"
|
CLIENT_HOST="http://localhost:5173"
|
||||||
JWT_SECRET=<jwt_secret>
|
JWT_SECRET=<jwt_secret>
|
||||||
DB_TYPE="MongoDB"
|
DB_TYPE="MongoDB"
|
||||||
DB_CONNECTION_STRING="mongodb://mongodb:27017/uptime_db"
|
DB_CONNECTION_STRING="mongodb://<username>:<password>@mongodb:27017/uptime_db"
|
||||||
REDIS_HOST="redis"
|
REDIS_HOST="redis"
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
TOKEN_TTL="99d"
|
TOKEN_TTL="99d"
|
||||||
@@ -187,14 +195,14 @@ SYSTEM_EMAIL_ADDRESS=<system_email>
|
|||||||
SYSTEM_EMAIL_PASSWORD=<system_email_password>
|
SYSTEM_EMAIL_PASSWORD=<system_email_password>
|
||||||
```
|
```
|
||||||
|
|
||||||
3. In the `Client` directory, create a `client.env` file with the [required environtmental variables](#env-vars-client) for the client. Sample file:
|
4. In the `Client` directory, create a `client.env` file with the [required environtmental variables](#env-vars-client) for the client. Sample file:
|
||||||
|
|
||||||
```
|
```
|
||||||
VITE_APP_API_BASE_URL="http://localhost:5000/api/v1"
|
VITE_APP_API_BASE_URL="http://localhost:5000/api/v1"
|
||||||
VITE_APP_API_LOG_LEVEL="debug"
|
VITE_APP_API_LOG_LEVEL="debug"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. In the `Docker` directory run `docker compose up` to run the `docker-compose.yaml` file and start all four images.
|
5. 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 80.
|
That's it, the application is ready to use on port 80.
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
Reference in new issue
Block a user