almalinux.org icon indicating copy to clipboard operation
almalinux.org copied to clipboard

Devcontainer support

Open alaurie opened this issue 1 year ago • 11 comments

This pull request introduces initial support for developing the Hugo site on AlmaLinux within a devcontainer. This setup enhances the development experience by providing a consistent, pre-configured environment directly from Visual Studio Code:

Devcontainer Features:

  • VSCode Extensions: Automatically installs the following extensions for optimal Hugo development: budparr.language-hugo-vscode - Hugo syntax support ms-python.python - Python development support esbenp.prettier-vscode - Code formatting yzhang.markdown-all-in-one - Enhanced Markdown editing tamasfe.even-better-toml - TOML language support

  • Terminal Configuration: Sets the integrated terminal to /bin/bash for a familiar shell experience.

  • Port Forwarding: Configures port 1313 to be forwarded for Hugo's live server.

  • User Configuration: Sets remoteUser to vscode, providing a secure, non-root user environment.

Dockerfile Setup:

  • Base Image: Utilizes the latest AlmaLinux image for compatibility and security.
  • System Updates: Ensures all system packages are up-to-date.
  • Software Installation: Includes essential tools like git, python3, python3-pyyaml, wget, tar, shadow-utils, and sudo.
  • Hugo Installation: Fetches and installs the latest Hugo extended binary for dynamic site generation.
  • User Management: Creates and configures a vscode user with sudo privileges to enhance security and usability.
  • Port Exposure: Exposes port 1313 to allow Hugo's development server to be accessed externally.

This setup aims to streamline the development process by automating the environment setup, ensuring consistency across different machines, and reducing the time spent on configuration. Please review and provide feedback or approval to merge.

alaurie avatar Dec 10 '24 02:12 alaurie

This looks fantastic! I'll give it a test tomorrow morning (local) to see if I can find any quirks.

What do you think about adding what you typed up in the PR to a README.md in the .devcontainer folder so people can see what it does at a glance (without looking for this PR)?

codyro avatar Dec 10 '24 03:12 codyro

@codyro Good idea, have added!

alaurie avatar Dec 10 '24 03:12 alaurie

Assuming we think this is ready to merge, I'll want to get a few community members to test it to ensure there are no lingering quirks and engage with anyone interested in helping out contributing (I just intend to ask in MatterMost, nothing fancy). Once we get some confirmation that everything works flawlessly, let's merge this as-is and then submit a new issue to add documentation. Or we could add documentation to this PR if we feel exceptionally motivated.

We could add a page (or multiple) on the wiki about how to use the devcontainers in projects to contribute (you said you're considering wiki after this, and I'll be looking to use it elsewhere).

codyro avatar Dec 11 '24 22:12 codyro

Documentation is critical and should be added along with these updates, so I'd like it to be part of this PR.

bennyvasquez avatar Dec 12 '24 21:12 bennyvasquez

Documentation is critical and should be added along with these updates, so I'd like it to be part of this PR.

It doesn't affect production. It's essentially the equivalent of adding a utility script that's unused. The scope of it being in a single PR isn't really realistic.

Splitting it up will be more effective in this case.

codyro avatar Dec 12 '24 21:12 codyro

Is this intended only for docker users? In my podman environment, it didn't work without adding --userns=keep-id to runArgs, which isn't available in docker so we can't simply add it here. I guess supporting both docker and podman out of the box is challenging.

pastalian avatar Dec 24 '24 17:12 pastalian

Is this intended only for docker users? In my podman environment, it didn't work without adding --userns=keep-id to runArgs, which isn't available in docker so we can't simply add it here. I guess supporting both docker and podman out of the box is challenging.

At the moment its just docker. I'll look into dual support with podman as well.

alaurie avatar Jan 17 '25 05:01 alaurie

@bennyvasquez @codyro

Documentation is critical and should be added along with these updates, so I'd like it to be part of this PR.

I've added in some further instructions in the readme.md around how the container is built and hugo live reloading on container start.

alaurie avatar Jan 17 '25 06:01 alaurie

I'm good with the documentation you've created so far, @alaurie! Once we think this is ready for everyone to adopt/use for themselves, adding a mention of it to the the root README would be awesome.

bennyvasquez avatar Jan 20 '25 22:01 bennyvasquez

I'm good with the documentation you've created so far, @alaurie! Once we think this is ready for everyone to adopt/use for themselves, adding a mention of it to the the root README would be awesome.

I've added a section to root README and linked to the README in the devcontainer directory.

alaurie avatar Jan 21 '25 07:01 alaurie

Nothing on my end, its working and I updated the docs in the repo on this commit.

alaurie avatar Feb 18 '25 06:02 alaurie

@trag-bot didn't find any issues in the code! ✅✨

trag-bot[bot] avatar Mar 04 '25 15:03 trag-bot[bot]

Pull request summary

  • Introduced a Dockerfile to set up a development container using AlmaLinux as the base image.
  • Added installation steps for essential packages including Git, Python, and Hugo, with dynamic version support for Hugo.
  • Created a non-root user (alma_www_user) with sudo privileges for enhanced security during development.
  • Configured the devcontainer to automatically install VSCode extensions tailored for Hugo development.
  • Set up port forwarding for Hugo's live server on port 1313 to facilitate real-time testing.
  • Updated the README to include instructions for contributing, bug reporting, and local development setup.
  • Added a devcontainer.json file to define the development environment configuration, including terminal settings and post-creation commands.
  • Enhanced documentation to clarify the process for accessing the live server and utilizing hot reloading features.
  • Improved user experience by ensuring the integrated terminal defaults to /bin/bash.
  • Provided troubleshooting tips for common issues related to Docker and port connectivity.

trag-bot[bot] avatar Mar 04 '25 15:03 trag-bot[bot]

Better late than never ;)

codyro avatar Mar 04 '25 15:03 codyro