Skip to content

Commit

Permalink
Fixing Docker-compose config for NodeJS
Browse files Browse the repository at this point in the history
  • Loading branch information
hannelita committed Aug 19, 2020
1 parent c220e65 commit 94ba9fc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
17 changes: 8 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ services:
env_file:
- .env
links:
- nodejs
# - solr
# - redis
# - datapusher
- "nodejs:nodejs"
ports:
- "0.0.0.0:80:${LEARNOCAML_PORT}"
expose:
Expand Down Expand Up @@ -47,13 +44,14 @@ services:
- "8000:8000"
expose:
- "8000"
environment:
- 'DB_CONN=mongodb://mongodb:27017/learn-ocaml-code'
- 'COMP_COLLECTION=compile-code'
- 'EVAL_COLLECTION=eval-code'
environment:
- PORT=8000
- DB_CONN=mongodb://mongodb:27017/learn-ocaml-code
- COMP_COLLECTION=compileCode
- EVAL_COLLECTION=evalCode
volumes:
- ./node:/node/app
- /node/app/node_modules
- node_modules:/node/app/node_modules
depends_on:
- mongodb

Expand All @@ -70,3 +68,4 @@ volumes:
sync:
learn-ocaml-sync:
mongodb_data_container:
node_modules:
18 changes: 16 additions & 2 deletions docs/howto-deploy-a-learn-ocaml-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,23 @@ If you have multiple dependencies (external projects), consider using Docker Com
* In your project root, `cp .env.example .env`
* Change the `REPOSITORY` variable on `.env` to point to the directory with your exercises

Build and start the environment with `build with docker-compose -f docker-compose.yml up --build`.
Build and start the environment with build with `docker-compose -f docker-compose.yml up --build`.

Now, access `localhost`.

### Useful Docker commands

`docker ps -a ` lists all the containers
`docker logs -f CONT_ID` Logs for a specific container
`docker restart CONT_ID` Restarts a container

`docker stop $(docker ps -aq)` - stops all running containers
`docker-compose -f docker-compose.yml up --build -d` - starts all containers in detached mode
`docker exec -it CONT_ID bash` - allows you to access the service (i.e. MongoDB) that is running
in a container



Now, access `localhost:8080`.

## Manual compilation

Expand Down
2 changes: 1 addition & 1 deletion src/toplevel/get-eval.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
get_eval();
function get_eval() {
const request = new XMLHttpRequest();
const path = "https://nodejs:8000/eval"; // server ip and port number
const path = "http://localhost:8000/eval"; // server ip and port number
try {
if (typeof (document.getElementsByClassName("ace_layer ace_text-layer")[0].innerHTML) !== 'undefined') {
request.open("POST", path, true); // true = asynchronous
Expand Down
3 changes: 2 additions & 1 deletion static/js/get-local-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ track_local_changes();

function track_local_changes() {
const request = new XMLHttpRequest();
const path = "http://nodejs:8000"; // server ip and port number
const path = "http://localhost:8000"; // server ip and port number
try {
if (typeof (document.getElementsByClassName("ace_layer ace_text-layer")[0].innerHTML) !== 'undefined') {
request.open("POST", path, true); // true = asynchronous
Expand All @@ -18,6 +18,7 @@ function track_local_changes() {
obj.nickname = nickname;
obj.timestamp = Date.now();
obj.solution = stringSolution;
console.log(stringSolution);
const jsonString = JSON.stringify(obj);
// send to Database
request.send(jsonString);
Expand Down

0 comments on commit 94ba9fc

Please sign in to comment.