这是indexloc提供的服务,不要输入任何密码
Skip to content

chore: dockerization of the tuono repo! #276

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

Merged
merged 17 commits into from
Jan 12, 2025

Conversation

spacecodeur
Copy link
Contributor

@spacecodeur spacecodeur commented Jan 1, 2025

Context & Description

I have dockerized the repo to simplify local development on the source code (one environment to rule them all!). To determine which packages to install and their order, I relied on the 'local development' documentation.

Everything has been isolated in a dedicated docker folder (to avoid adding extra configuration files at the root of the project).

Currently, packages such as pnpm, turbo, and cargo are properly installed, and tuono (seems) compiles correctly. I noticed that the Node version is currently managed via the /.nvmrc file. To streamline the build process (and centralize versioning) with Docker, I have transferred this version into the docker/compose.yml file.

How to use Docker (with this current work)

Firstly, install docker and docker compose.
Then navigate to the root of the project using your terminal, then...

  • Build the Docker container : docker compose -f docker/compose.yml up --build -d
  • List active images and containers : docker images && docker ps -a --size
  • Connect to the container : docker exec -it tuono-source-container /bin/bash
  • (bonus) Delete all Docker images/containers/volumes + caches (caution here!) :
docker ps -q | \
xargs -r docker stop && docker ps -aq | \
xargs -r docker rm -v && docker network prune -f && docker system prune -af --volumes && docker images -q | \
xargs -r docker rmi

The docker container's responsability is to handle all the project environment. That's mean you have only to just install your prefered IDE (like vscode by example), connect it to the docker container and the dev can begin ! The code source is sync between container and host ; at the end, you can git add/commit/push/... from your host machine.

To do

  • I can't run the web server for the documentation website (the tuono dev command seems work well, but a curl http://127.0.0.1:3000 from container failed). I haven't found how to fix this problem yet..
  • The command turbo check-all does not work (turbo error : could not find task check-all in project). I have to run directly turbo build lint format:check types --filter='!./examples'
  • Since I don't know the Turbo tool very well, I haven't delved too deeply into it with Docker yet. I assume there's some work to be done on that front

Once the work with Docker is complete, I can suggest updating the documentation to summarize how to use it, if you'd like :)

marcalexiei

This comment was marked as outdated.

@marcalexiei marcalexiei changed the title Dockerization the tuono codesource repo ! chore: dockerization of the tuono repo! Jan 1, 2025
@marcalexiei marcalexiei added the repo maintenance linting, fs organization, that sort of stuff label Jan 1, 2025
@spacecodeur
Copy link
Contributor Author

I can't run the web server for the documentation website (the tuono dev command seems work well, but a curl http://127.0.0.1:3000 from container failed). I haven't found how to fix this problem yet..

Is the error something like this?

thread 'main' panicked at crates/tuono/src/cli.rs:111:18:
Failed to build tuono.config.ts: Os { code: 2, kind: NotFound, message: "No such file or directory" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Its not this error, I indeed run the pnpm install command from the .../app/documentation dir then the tuono dev command from the same dir. (I work only from the container here)
No error occured, my terminal shows :

⚡ Tuono v0.16.9
Ready at: http://localhost:3000

But if I open my browser from my host machine, I get the error :

image

Maybe its about a bad config with the network and docker compose. So, in another terminal from the container, I tried to run a curl http://127.0.0.1:3000 command directly from the docker container and I get the error :

curl: (7) Failed to connect to 127.0.0.1 port 3000 after 0 ms: Couldn't connect to server

Currently I stoped my investigations with theses two commands from the container :

  • the ps aux | grep tuono :
root        1068  0.0  0.0 2256996 15784 pts/1   Sl+  Jan01   0:00 tuono dev
root        1123  0.4  0.2 22635660 136100 pts/1 Sl+  Jan01   0:00 node node_modules/.bin/../tuono/bin/watch.js
root        1223  0.0  0.0 724468 15388 pts/1    Sl+  Jan01   0:00 /tuono/node_modules/.pnpm/@esbuild+linux-x64@0.21.5/node_modules/@esbuild/linux-x64/bin/esbuild --service=0.21.5 --ping
root        1535  0.0  0.0   3324  1456 pts/2    S+   00:00   0:00 grep tuono
  • and the netstat -anp command : (I installed manually netstat for debug ;) )
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 172.17.0.2:3000         172.17.0.1:53222        TIME_WAIT   -                   
tcp6       0      0 ::1:3001                :::*                    LISTEN      1123/node           
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  3      [ ]         STREAM     CONNECTED     513913   1123/node            
unix  3      [ ]         STREAM     CONNECTED     513915   1123/node            
unix  3      [ ]         STREAM     CONNECTED     513916   1223/esbuild         
unix  3      [ ]         STREAM     CONNECTED     513914   1223/esbuild         
unix  3      [ ]         STREAM     CONNECTED     520744   1068/tuono           
unix  3      [ ]         STREAM     CONNECTED     520745   1068/tuono

the processus tuono dev is running, but the port 3000 seems not to be well used.. I'll continue to investigate later :)

@Valerioageno
Copy link
Member

Thanks for this! This is a great addition.
Maybe later I'll take a look at the port binding issue! 😄

@Valerioageno
Copy link
Member

I tested the configuration locally and everything works! ⚡

I noticed that I had to do again pnpm install on the root. Is that expected?

@spacecodeur
Copy link
Contributor Author

I tested the configuration locally and everything works! ⚡

Yeah !

I noticed that I had to do again pnpm install on the root. Is that expected?

Hmmm its not normal because this command is ran during the container building (the line RUN ["pnpm", "install"] at the end of the Dockerfile)

@Valerioageno
Copy link
Member

@spacecodeur Could you please check out the needed pnpm install? I tried again and it seems required. It is not a big deal, but it would be great to avoid that before merging!

great improvement btw!

@marcalexiei
Copy link
Collaborator

Once the work with Docker is complete, I can suggest updating the documentation to summarize how to use it, if you'd like :)

Also, could you please also update the documentation adding a section about docker in Local development?

Warning

We just updated the documentation site.
To avoid conflicts be sure to merge changes from main before updating that page

@marcalexiei marcalexiei changed the title chore: dockerization of the tuono repo! chore: dockerization of the tuono repo Jan 5, 2025
@marcalexiei marcalexiei changed the title chore: dockerization of the tuono repo chore: dockerization of the tuono repo! Jan 5, 2025
@spacecodeur

This comment was marked as resolved.

@marcalexiei

This comment was marked as resolved.

@marcalexiei

This comment was marked as resolved.

@marcalexiei
Copy link
Collaborator

marcalexiei commented Jan 5, 2025

@spacecodeur since you checked "Maintainers are allowed to edit this pull request" I'm going to try to fix the branch.


FYI next time happen something like this use git reflog to revert this kind of changes.

TL; DR; Git reflog keeps track of every action you perform in the repository

Copy link
Collaborator

@marcalexiei marcalexiei left a comment

Choose a reason for hiding this comment

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

Unfortunately the "manual pnpm install" is still required to make the image work.
I also noticed an additional improvement that can be made to install the proper version of pnpm.

I have created two threads to discuss each point easily.

@Valerioageno
Copy link
Member

@spacecodeur documentation code formatting CI is failing. You should run pnpm docs:format and submitting the changes.

marcalexiei
marcalexiei previously approved these changes Jan 7, 2025
Copy link
Collaborator

@marcalexiei marcalexiei left a comment

Choose a reason for hiding this comment

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

LGTM!

I prefer to wait that @Valerioageno test the image on a Windows machine before merging (just to be sure).

@spacecodeur
Copy link
Contributor Author

@spacecodeur documentation code formatting CI is failing. You should run pnpm docs:format and submitting the changes.

Ill take a look soon

@spacecodeur spacecodeur closed this Jan 8, 2025
@spacecodeur spacecodeur reopened this Jan 8, 2025
@marcalexiei
Copy link
Collaborator

I had already fixed the format issue yesterday.
No action is required at the moment.

@spacecodeur
Copy link
Contributor Author

spacecodeur commented Jan 8, 2025

LGTM!

I prefer to wait that @Valerioageno test the image on a Windows machine before merging (just to be sure).

Already tested on Windows! But two tests are always better than one.
(sorry for the close/open PR, it was a miss click)

@marcalexiei
Copy link
Collaborator

@spacecodeur is possibile to test the image building via GitHub actions?
This way we can test image is building correctly across unix-like and windows platforms and we don't introduce bugs with in the future.

@spacecodeur
Copy link
Contributor Author

@marcalexiei
hmmm I'm not familiar with github action , but I can take a look with pleasure
I’ll probably reach out to you on Discord before the end of the week :)

@Valerioageno
Copy link
Member

Hey guys! I'm travelling right now. I expect to test it the first days of the next week!

@Valerioageno
Copy link
Member

On windows' Docker I get the following error.

Screenshot 2025-01-11 195714

Works like a charm when I use WLS and run Docker from within

@Valerioageno
Copy link
Member

Probably it is just a problem with my dirty containers setup. I use WLS and I tried to install Docker directly on windows. Maybe something went wrong with WLS. If windows works for you we can merge.

Just fix the CI pipelines!

@marcalexiei marcalexiei merged commit f9545f5 into tuono-labs:main Jan 12, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repo maintenance linting, fs organization, that sort of stuff
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants