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

Updated Dockerfile .bashrc creation to be more readable #18

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

BruceMcRooster
Copy link
Member

@BruceMcRooster BruceMcRooster commented Jan 15, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This makes the actual script that is written to ~/.bashrc by the Dockerfile more readable.
Readability is usually a good thing. Just look at this.

RUN printf '\n# automatically generated by Dockerfile \n\
source "/opt/ros/humble/setup.bash" --                \n\
cd rb_ws                                              \n\
colcon build --symlink-install                        \n\
source install/local_setup.bash                       \n\
chmod -R +x src/buggy/scripts/                        \n\
source environments/docker_env.bash                   \n\
\n' >> ~/.bashrc

Beautiful 👌

Related Tickets & Documents

I referenced making a change like this when reviewing another PR; here was my comment. It was slightly modified to ensure consistency and that it worked

Testing

This has been tested in the Docker container, but if you want to try it yourself, boot up a container. You shouldn't see any errors in the Dockerfile or in bash when it starts up. Checking the bottom of ~/.bashrc should show the correct code, reproduced below, with no weird trailing characters, aside from some spaces that were added for better formatting of the Dockerfile.

# automatically generated by Dockerfile 
source "/opt/ros/humble/setup.bash" --                
cd rb_ws                                              
colcon build --symlink-install                        
source install/local_setup.bash                       
chmod -R +x src/buggy/scripts/                        
source environments/docker_env.bash                   

@BruceMcRooster
Copy link
Member Author

I used printf because it supports \n everywhere, while echo typically requires the -e flag and I was having problems where it was including -e in the output.

@mehulgoel873 mehulgoel873 merged commit 79ab955 into main Jan 15, 2025
3 checks passed
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.

2 participants