-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
46 updated use GitHub codespaces #103
base: main
Are you sure you want to change the base?
Conversation
Dockerfile
Outdated
RUN /workspace/venv/bin/pip install --upgrade pip | ||
|
||
# Install dependencies in smaller groups to identify the problematic package | ||
RUN /workspace/venv/bin/pip install \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we convert this back to installing the requirements.txt
file?
install_docker.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file being used somewhere?
get-docker.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file being used somewhere?
.devcontainer/devcontainer.json
Outdated
"forwardPorts": [8000, 5432, 9200], | ||
// "postCreateCommand": "sudo usermod -aG docker $USER && sudo service docker start", | ||
"postCreateCommand": "sudo usermod -aG docker $USER", | ||
"postStartCommand": "bash cleanup_and_start.sh", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you find that we needed to do this sort of cleanup and starting of Docker for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started a Codespace off the main
branch and did a docker info
- Docker should be installed and run by default.
@tyliec ➜ /workspaces/uipa (main) $ docker info
Client:
Version: 26.1.3-1
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.14.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.27.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
...
Not sure if you found some sort of timing issue or not here though
Dockerfile
Outdated
FROM mcr.microsoft.com/devcontainers/javascript-node:22 | ||
|
||
# Install main dependencies and Docker in one step to reduce layers | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need all of these packages? Codespaces should have a lot of these by default already - i.e. git
, cmake
, ...etc.
From a new Codespace:
@tyliec ➜ /workspaces/uipa (main) $ dpkg -l cmake
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-=======================-============-=======================================
ii cmake 3.16.3-1ubuntu1.20.04.1 amd64 cross-platform, open-source make system
Dockerfile
Outdated
@@ -0,0 +1,123 @@ | |||
# FROM mcr.microsoft.com/devcontainers/javascript-node:1-18 | |||
FROM mcr.microsoft.com/devcontainers/javascript-node:22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason you chose this base image? Given this is a Python / Django project primarily, I would take a look at https://github.com/devcontainers/images/tree/main/src/python instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should talk about this PR - but I would take a closer look at https://github.com/devcontainers/templates/tree/main/src/python for a few examples of implementation, and maybe https://containers.dev/ for a general idea of the specification
.devcontainer/devcontainer.json
Outdated
"dockerfile": "../Dockerfile" | ||
}, | ||
"runArgs": [ | ||
"--init", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason we chose to user a Docker in Docker approach here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the DinD (Docker in Docker) approach is used to allow starting up the database and search engine from a terminal in the dev container. The dev container's postStartCommand property says to run the cleanup_and_start.sh
script. It in turn runs docker-compose
to start the dev web server, database, and search engine in containers.
The way I read the Dev Containers docs, I'm guessing that using a docker-compose.yml file in the build
property of the devcontainer.json
file, the database and search engine could be run automatically along side the dev web server without having to run them all from inside a dev container.
In the existing docker-compose.yml
file, if you rename the newly added web
service to devcontainer
that will be the main dev container and the db
and elasticsearch
services will be additional containers accessible by the dev container. See https://containers.dev/guide/dockerfile#docker-compose. Of course, other changes would be required to have things play nicely.
A doc about how use a dev container for new people (possible contributors) to help them get up and running quickly should be included. It should say what this dev container set-up provides for a developer or person who wants to run the website.
Also, if I'm not mistaken, if we set up the dev container to use docker-compose.yml
then it would also be possible for people to use it locally without running a dev container. While the free GitHub personal account provides a limited amount of Codespaces resources to run dev containers, it is better not to be required to use Codespaces as it may incur costs that people aren't willing to pay.
Opening the
There are libraries that are missing in the dev container. The database and search engine are not accessible from the dev container. |
What state do we want the dev container to be in after it's been started up and attached to by the GitHub web interface? I think that there are two audiences with different needs:
The non-developer would like to be able to go to the web app and start playing with it; not open a terminal window and type commands in. The developer should be OK with opening a terminal window and typing in commands. I think that both can be accomodated. It's very important that a document that provides guidance be provided so that new contributors can come up to speed quickly and easily. |
Dockerfile
Outdated
RUN pip install -r requirements.txt | ||
|
||
# Start Docker daemon | ||
CMD ["sudo", "service", "docker", "start"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be sleep infinity
, or this should be specified as sleep infinity
in the devcontainer.json
180daca
to
4950ede
Compare
… up sudo docker-compose up --build
b7485d2
to
ccc3fcc
Compare
…s not passing health check
… an error with django-configurations
…o attribute 'geo_db_type'
…sult: Confirmed that both are accessible with: sudo docker exec -it devcontainer_app_1 /bin/bash psql --version curl --version
… has no attribute 'geo_db_type'
Start a Fresh Codespace ( ~ 5 minutes )
Run the Codespace ( ~ 15 minutes )
Steps based on the 'Quick Start' guide from the 'Getting Started' documentation
https://github.com/CodeWithAloha/uipa/blob/main/docs/Getting-Started.md
docker ps
. (if this is not running, then rundocker-compose up
)yarn build
.bash data/seed/init_db.sh
.python manage.py runserver
.