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

[FEAT] Make the Dockerfile be able to support itself + fix various issues #4

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

itislu
Copy link
Contributor

@itislu itislu commented Feb 6, 2025

The Dockerfile can now be used on its own and does not rely on the devcontainer or docker-compose anymore.
The role of the devcontainer and docker-compose are to just make it easier to have some configuration in one place and to not have to remember the long docker commands.


Features

  • Install scan-build.
  • Install ncdu.
  • Install man and manpages, also for MLX.
  • Share zsh history with host.
  • Add support for .env file.
    All important environment variables, like USERNAME, UID, GID and WORKSPACE_FOLDER can be configured this way.

Improvements

  • Containers created by devcontainer and docker-compose behave exactly the same for the user now.
  • Mount .ssh directory read-only.
  • Use multistage build to reduce final image size.
  • Improve build speed by compiling with all CPU cores (make -j).

Changes

  • Remove duplicate Dockerfile and always install .devcontainer.
  • Don't mount .zshrc by default.
    I can imagine users of this container might sometimes have broken zshrc files. I left a commented out line to load .zshrc from the local environment if the user really wants it.
  • Mounted workspace is now always in /workspace/<project_directory>.
  • Rename compose service from run-container to 42-docker-devenv.

Fixes

  • Fix "dubious ownership" issues with git by creating a user in the container.
    What's important is that the UID and GID match with the user who created the local repository.
  • Fix francinette alias for zsh.

Style

  • Sort package installs by category and alphabetically.

Documentation

  • Add note that first time building can take some time.
  • Add command to attach to container in the shell.

@itislu itislu marked this pull request as draft February 6, 2025 11:26
@itislu itislu force-pushed the feat-self-contained-dockerfile branch from 301a395 to b057d01 Compare February 8, 2025 09:44
itislu added a commit to itislu/42-CPP_Modules that referenced this pull request Feb 8, 2025
@itislu itislu force-pushed the feat-self-contained-dockerfile branch from b057d01 to b2a8b4f Compare February 8, 2025 13:54
@itislu itislu force-pushed the feat-self-contained-dockerfile branch from 89741c0 to 1c0efe8 Compare February 8, 2025 21:04
It looks like git overwrites the .gitconfig file when it changes something. This is not possible however because the file is mounted to the host file system, so it cannot be replaced, only the content can be changed.
The fix is to mount it somewhere else (read-only) and then copy it to the desired place at container start.
Because everything in the user's home directory is now a copy and not directly mounted anymore, this also has the side effect that the user can now freely experiment with the .gitconfig in the container.

Also:
- FIx syntax to mount read-only in docker-compose.
  False: `readonly`
  Correct: `ro`
@itislu itislu force-pushed the feat-self-contained-dockerfile branch from 1c0efe8 to 0715700 Compare February 9, 2025 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant