Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CloudComputing_Act1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jesus Galaz Reyes
CloudComputing_Act1
Commits
b528faec
Commit
b528faec
authored
7 months ago
by
Rokas Stankunas
Browse files
Options
Downloads
Plain Diff
Merge branch '15-secure-database' into 'main'
Implementing "Secure database" issue Closes
#15
See merge request
!11
parents
aa9154e0
faa06005
No related branches found
Branches containing commit
No related tags found
1 merge request
!11
Implementing "Secure database" issue
Pipeline
#16865
passed
6 months ago
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+14
-6
14 additions, 6 deletions
README.md
docker-compose.yml
+8
-2
8 additions, 2 deletions
docker-compose.yml
mongodb.js
+6
-3
6 additions, 3 deletions
mongodb.js
with
28 additions
and
11 deletions
README.md
+
14
−
6
View file @
b528faec
...
...
@@ -18,7 +18,7 @@ e.g., using BCRYPT)
Develop a TODO app that fulfills the requirements from above. You can use any language
and framework that you want. The app needs to be connected to a database to store the TODO
lists.
**
Use MongoDB as the database.
**
lists. Use MongoDB as the database.
---
## Prerequisites
-
Git
...
...
@@ -32,11 +32,19 @@ In exercise 1, the deployment consisted of 2 parts: deploying the database and t
`git clone https://gitlab.reutlingen-university.de/gajesh24/cloudcomputing_act1.git`
2.
Enter the folder:
`cd cloudcomputing_act1`
3.
Build the image:
`sudo docker build -t todo-app .`
4.
Start docker compose file
`sudo docker compose up -d`
5.
Open up website on
`http://localhost/`
3.
Create .env file with the following contents:
`
MONGO_INITDB_ROOT_USERNAME=mongoAdmin
MONGO_INITDB_ROOT_PASSWORD=someRandomPassword123
MONGO_URI=mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@mongodb:27017/todo-app?authSource=admin
`
4.
Build the application
`sudo docker compose build`
5.
Run the application
`sudo docker compose --env-file .env up -d`
6.
Open up website on
`http://localhost/`
7.
To stop the application
`sudo docker compose stop`
---
## Authors
...
...
This diff is collapsed.
Click to expand it.
docker-compose.yml
+
8
−
2
View file @
b528faec
...
...
@@ -4,13 +4,19 @@ services:
container_name
:
mongodb
ports
:
-
"
27017:27017"
environment
:
-
MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME}
-
MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD}
-
MONGO_INITDB_DATABASE=todo-app
todo-app
:
image
:
todo-app
build
:
context
:
.
dockerfile
:
Dockerfile
container_name
:
todo-app
ports
:
-
"
80:3000"
depends_on
:
-
mongodb
environment
:
-
MONGO_URI=
mongodb://mongodb:27017/todo-app
-
MONGO_URI=
${MONGO_URI}
This diff is collapsed.
Click to expand it.
mongodb.js
+
6
−
3
View file @
b528faec
const
mongoose
=
require
(
'
mongoose
'
);
require
(
'
dotenv
'
).
config
();
const
mongoose
=
require
(
"
mongoose
"
);
require
(
"
dotenv
"
).
config
();
const
connectDB
=
async
()
=>
{
try
{
const
conn
=
await
mongoose
.
connect
(
process
.
env
.
MONGO_URI
||
"
mongodb://mongodb:27017/todo-app
"
);
const
conn
=
await
mongoose
.
connect
(
process
.
env
.
MONGO_URI
,
{
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
});
console
.
log
(
`MongoDB connected:
${
conn
.
connection
.
host
}
`
);
}
catch
(
err
)
{
console
.
error
(
`Error:
${
err
.
message
}
`
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment