Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test collab changes #4041

Draft
wants to merge 1 commit into
base: test-collab
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
*~
environment
30 changes: 21 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
name: musicblocks
services:
musicblocks:
build: https://github.com/sugarlabs/musicblocks.git#collaboration
# build: https://github.com/sugarlabs/musicblocks.git#test-collab
build:
context: ./
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this was needed for a test, the idea here is to build from this repo and not local sources.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I tried this lots of time but it was not building the image from the remote repo (my network can be the reason, I'll try again). Just for testing purpose, I tried to build using the local repo as it contains the same code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably an issue with your network, did you try again and did it work?

If it's your network then you can do this locally without committing it.

ports:
- "3000:3000"
#command: ["python", "-m", "http.server", "3000", "--bind", "0.0.0.0"]
command: ["python", "-m", "http.server", "3000", "--bind", "0.0.0.0"]
env_file:
- ./environment
#planet-server:
# build:
# dockerfile: ./planet-server/Dockerfile
#volumes:
# - planet-server/planet.sql:
planet-mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: planet
volumes:
- /Users/ajeetpratapsingh/Developer/os/planet-server/planet.sql
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be great if you don't hard code values like this because if I was testing, I wouldn't have that directory and that'll break things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created a local db planet-mysql for testing purpose and I assume, we will also have a db on our remote server to reference a volume like this and this path /Users/ajeetpratapsingh/Developer/os/planet-server/planet.sql will be changed to server's local path. is there any better way to add volume, like fetching from somewhere?

Copy link
Member

@chimosky chimosky Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just reference a volume with it's name and it'll automatically be created if it doesn't exist, no need for a path to an existing volume.

If you want to mount a db that's part of the repo in the container, then that's something you can still do.

ports:
- "3306:3306"
planet-server:
build:
dockerfile: ../planet-server/Dockerfile
ports:
- "8080:8080"
collaboration-server:
#build: https://github.com/sugarlabs/collaboration-server.git
build:
dockerfile: ./collaboration-server/Dockerfile
dockerfile: ../collaboration-server/Dockerfile
volumes:
- .:/collaboration-server
environment:
NODE_ENV: development
#command: ["npm", "run", "server"]
command: ["npm", "run", "serve"]
command: ["npm", "run", "server"]

4 changes: 2 additions & 2 deletions js/collaboration/collaboration.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Collaboration {
this.attempts = 0;
this.socket = null;
this.blockList = this.activity.blocks.blockList;
this.HOST = process.env.COLLAB_HOST;
this.HOST = "http://127.0.0.1";
this.PORT = "8080";
this.hasCollaborationStarted = false;
this.updatedProjectHtml = null;
Expand Down Expand Up @@ -64,7 +64,7 @@ class Collaboration {
// Make calls to the socket server
makeConnection = (room_id, name) => {
// connect to the local server
const socket = io(this.HOST.concat(";", this.PORT));
const socket = io(this.HOST.concat(":", this.PORT));
socket.on("connect", () => {
this.socket = socket;
try {
Expand Down
5 changes: 3 additions & 2 deletions planet/js/ServerInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ServerInterface {

constructor(Planet) {
// this.ServerURL = "https://musicblocks.sugarlabs.org/planet-server/index.php";
this.ServerURL = "http://localhost:3000/planet-server/index.php");
this.ServerURL = "http://0.0.0.0:8080/planet-server/index.php";
this.ConnectionFailureData = {"success": false, "error": "ERROR_CONNECTION_FAILURE"};
this.APIKey = process.env.API_KEY;
this.APIKey = "3f2d3a4c-c7a4-4c3c-892e-ac43784f7381";
}

request (data, callback) {
Expand All @@ -42,6 +42,7 @@ class ServerInterface {
})
.done(data => {
callback(data);
console.log("success", data);
})
.fail(() => {
callback(this.ConnectionFailureData);
Expand Down