-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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: Docker development environment #1337
Open
ojeytonwilliams
wants to merge
6
commits into
freeCodeCamp:main
Choose a base branch
from
ojeytonwilliams:feat/docker-dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0d79a2
feat: create docker dev environment
ojeytonwilliams a8fd9e1
feat: add devuser to sudoers
ojeytonwilliams 5c7a9fe
docs: add Docker guide to CONTRIBUTING.md
ojeytonwilliams 8f1d402
fix: clarify which code is dev only
ojeytonwilliams f1018d7
fix(docs): add missing Docker guide
ojeytonwilliams c1af9ce
fix: include attribution
ojeytonwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
.DS_Store | ||
.bundle | ||
.bash_history | ||
.env | ||
log | ||
tmp | ||
public/assets | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM ruby:2.6.5 | ||
|
||
ENV LANG=C.UTF-8 | ||
ENV ENABLE_SERVICE_WORKER=true | ||
|
||
ARG USER_ID | ||
ARG GROUP_ID | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install git nodejs libcurl4 sudo && \ | ||
gem install bundler | ||
|
||
# Create the dev user, add them to sudoers and set up a home dir | ||
# Adapted slightly from this excellent blog post: | ||
# https://jtreminio.com/blog/running-docker-containers-as-current-host-user | ||
RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \ | ||
groupadd -g ${GROUP_ID} devuser &&\ | ||
useradd -l -u ${USER_ID} -g devuser devuser &&\ | ||
usermod -aG sudo devuser &&\ | ||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers &&\ | ||
install -d -m 0755 -o devuser -g devuser /home/devuser &&\ | ||
chown --changes --silent --no-dereference --recursive \ | ||
--from=33:33 ${USER_ID}:${GROUP_ID} \ | ||
/home/devuser \ | ||
;fi | ||
|
||
# Host directories cannot be mounted by Dockerfiles so we have to use | ||
# a temporary directory to hold the lock files while the gems are installed. | ||
WORKDIR /devdocs/ | ||
|
||
COPY Gemfile Gemfile.lock Rakefile /devdocs/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Running
(Not exactly sure how it is meant to be used, though…) |
||
|
||
RUN bundle install && rm -rf /devdocs/ | ||
|
||
WORKDIR /home/devuser/ | ||
|
||
EXPOSE 9292 | ||
|
||
# This entrypoint lets you | ||
# docker-compose run --rm --service-ports devdocs | ||
# straight into a bash shell | ||
ENTRYPOINT [ "/bin/bash" ] | ||
|
||
USER devuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3.7' | ||
services: | ||
devdocs: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile-dev | ||
args: | ||
USER_ID: ${USER_ID:-0} | ||
GROUP_ID: ${GROUP_ID:-0} | ||
volumes: | ||
- ${PWD}:/home/devuser | ||
ports: | ||
- "9292:9292" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Docker development config | ||
USER_ID=1000 | ||
GROUP_ID=1000 | ||
COMPOSE_FILE=docker-compose.dev.yml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The section is missing in the file (has not been committed)?