Sage-Bionetworks / sage-monorepo

Where OpenChallenges, Schematic, and other Sage open source apps are built
https://sage-bionetworks.github.io/sage-monorepo/
Apache License 2.0
22 stars 12 forks source link

Document how to prepare EC2 for running remote dev containers #172

Closed tschaffter closed 2 years ago

tschaffter commented 2 years ago

In AWS Management Console

On your local host

On the EC2 instance

In VS Code

Congratulations, you are now ready to develop in the dev container that runs on the EC2 instance! 🚀

tschaffter commented 2 years ago

I can now ping the devcontainer after adding this inbound rule:

Type: Custom ICMP rule
Protocol: Echo Request
Port: N/A
Source: your choice (I would select Anywhere to be able to ping from any machine)
tschaffter commented 2 years ago

test.challenge-registry.org and my devcontainer EC2 have virtually the same security group. One may difference is that the dockerized app on the test server is running on the host's docker engine, while I'm currently running the containers in the devcontainer using the VS Code option docker-in-docker.

I tried the option docker-from-docker that now makes the devcontainer use the host's docker engine. I can now successfully start the app and access it my copy-pasting the private IP address in my browser.

A simple solution is to use docker-from-docker instead of docker-in-docker. Using an EC2 provide in itself all the isolation we need from our local computer.

Here are the containers running on the EC2:

$ docker ps
CONTAINER ID   IMAGE                                                                  COMMAND                  CREATED          STATUS          PORTS                                           NAMES
c99141320412   sagebionetworks/challenge-registry-web-app:latest                      "/docker-entrypoint.…"   12 seconds ago   Up 10 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp               challenge-registry-web-app
06492c258030   sagebionetworks/challenge-registry-api:latest                          "/docker-entrypoint.…"   12 seconds ago   Up 11 seconds   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp       challenge-registry-api
8a61ce97eb44   sagebionetworks/challenge-registry-api-db:latest                       "docker-entrypoint.s…"   12 seconds ago   Up 11 seconds   0.0.0.0:27017->27017/tcp, :::27017->27017/tcp   challenge-registry-api-db
3cd9a49270cc   vsc-challenge-registry-0fa1610b06cbe44dd8da6b5412593805-features-uid   "/bin/sh -c 'echo Co…"   7 minutes ago    Up 7 minutes                                                    quizzical_gates
tschaffter commented 2 years ago

Exploring how VS Code forward port with the option docker-in-docker. The following port info is visible after starting the devcontainer. None of the stack containers are running yet.

image

Now I start the stack with docker compose up -d:

image

tschaffter commented 2 years ago

Note about the port issue

I realized that I can access the challenge registry running INSIDE the devcontainer on the EC2 using localhost (using docker-in-docker). 🤯