Skip to content

Commit

Permalink
Update devcontainer to use new public container (#83)
Browse files Browse the repository at this point in the history
* Update Dockerfile

* remove prior code tours steps

* Add new dockerfile steps to tour
  • Loading branch information
SeanKilleen authored May 24, 2022
1 parent d4f4ab3 commit c8dd87e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 108 deletions.
45 changes: 2 additions & 43 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
# Adapted from https://github.com/timbru31/docker-ruby-node/blob/master/2.7/16/Dockerfile
# Using dependency references from https://pages.github.com/versions/

# 2.7.3 is GitHub Pages 226 compatible
ARG RUBY_VERSION=2.7.3


FROM ruby:${RUBY_VERSION}

ARG GH_PAGES_VERSION=226
ARG NODE_MAJOR_VERSION=16

LABEL maintainer="Sean Killeen <[email protected]>"
# Our own public container that we've published to assist with this project
FROM ghcr.io/excellalabs/blog-in-a-box-container:ruby2.7.3-node16

VOLUME /docs

WORKDIR /docs

######################################################
# Installling Base + Ruby Stuff #
######################################################

RUN apt-get -y update

RUN apt-get -y install \
git \
tzdata \
dos2unix

RUN gem install bundler

#################################################################
# Installing node #
#################################################################

RUN curl -sL https://deb.nodesource.com/setup_${NODE_MAJOR_VERSION}.x | bash -\
&& apt-get update -qq && apt-get install -qq --no-install-recommends \
nodejs \
&& apt-get upgrade -qq \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*\
&& npm install -g yarn@1

RUN node -v
RUN npm -v
RUN npm install -g cspell markdownlint-cli

COPY aliases.sh /etc/profile.d/alias.sh

# Coverts CRLF based files (such as those on windows devices) to LF line endings for container
Expand Down
80 changes: 15 additions & 65 deletions .tours/bloginabox-tour.tour
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
"description": "Blog in a box is made to run in something called a \"dev container\". This means that all of the dependencies -- ruby, jekyll, the right version of node, the tooling packages -- are all wrapped up in a container that you can open this code in. You can do that within VS Code, or you can do it via GitHub Codespaces and develop in the browser, all while getting the same consistent tooling.",
"line": 2
},
{
"file": ".devcontainer/Dockerfile",
"description": "We were too limited by the out of the box Jekyll container, and wanted something we could customize to our needs.\n\nBut, we didn't want to have to pay a large time cost each time we built our development environment.\n\nSo, we created [a container specifically for our use](https://github.com/excellalabs/blog-in-a-box-container) and published it [on the GitHub Packages Container Registry](https://github.com/excellalabs/blog-in-a-box-container/pkgs/container/blog-in-a-box-container).\n\nAs the tag infers, this container currently uses Ruby `2.7.3` and node `16.x`. Ruby 2.7.3 is used because it is what is listed as compatible with the latest GitHub pages.",
"line": 2
},
{
"file": ".devcontainer/Dockerfile",
"description": "Here, we copy our aliases file to `/etc/profile.d`. We originally thought this would get our alises sources upon startup, but that didn't happen. Still, it seems like a fine enough place to put the file.",
"line": 7
},
{
"file": ".devcontainer/Dockerfile",
"description": "This ensures that our aliases will be available to us when we open the terminal.",
"line": 12
},
{
"file": ".devcontainer/devcontainer.json",
"description": "We have a custom Docker file that we use to create our dev container. We'll get to that in a little bit.",
Expand Down Expand Up @@ -61,71 +76,6 @@
"file": ".devcontainer/aliases.sh",
"description": "This is the aliases file. We use this to create some \"shortcuts\". When you open the terminal within the devcontainer, you can for example type `build` rather than the longer jekyll build statement. The aliases commands tend to ensure that you're in the right folder within the container as well.",
"line": 1
},
{
"file": ".devcontainer/Dockerfile",
"description": "Our Dockerfile is what actually builds and drives the development environment.\n\nWe previously pulled from the official Jekyll images, but found those to not be nearly as flexible as we needed them to be.\n\nSo now, we pull from the base Ruby image, at a version compatible with GitHub pages. We then install node and our packages into that images ourselves.\n\nIn the future, we'll probably move this into its own container so that it won't have to build each time, and thus dev environments will start much faster.",
"line": 1
},
{
"file": ".devcontainer/Dockerfile",
"description": "Here, we use the `ARG` command -- this lets us set a variable at build time to specify the ruby version. ",
"line": 5
},
{
"file": ".devcontainer/Dockerfile",
"description": "This pulls the container from the official ruby container at the specified version.",
"line": 8
},
{
"file": ".devcontainer/Dockerfile",
"description": "We also set variables for GH Pages and the node major version. The goal is to use the GitHub pages dependency and try to keep all the things synced up for the right versions.",
"line": 10
},
{
"file": ".devcontainer/Dockerfile",
"description": "Feel free to reach out to me anytime via https://SeanKilleen.com as well.",
"line": 13
},
{
"file": ".devcontainer/Dockerfile",
"description": "Ensures we can do git stuff in the dev container",
"line": 26
},
{
"file": ".devcontainer/Dockerfile",
"description": "Ensures we have updated time zone info.",
"line": 27
},
{
"file": ".devcontainer/Dockerfile",
"description": "`dos2unix` is used to make sure our alias file, which might be edited on Windows, always has the appropriate character encoding in unix environments.",
"line": 28
},
{
"file": ".devcontainer/Dockerfile",
"description": "Here's where we install node, passing the major version we want to the curl URL for nodesource.",
"line": 36
},
{
"file": ".devcontainer/Dockerfile",
"description": "We do this just to ensure we know what versions we're using in the container. Just a reference for us at build time more than anything.",
"line": 44
},
{
"file": ".devcontainer/Dockerfile",
"description": "We copy the aliases to the profile directory. Initially we thought this would automatically add them, but it does not, which is all good. We still keep them there just because it seems like a fine place for them.",
"line": 48
},
{
"file": ".devcontainer/Dockerfile",
"description": "Here, we add our alias file to the bash profile. This way, when an interactive prompt shows up, the aliases will already be loaded, and you can type `localdev` or `spellcheck`, etc. and have it just work.",
"line": 53
},
{
"file": ".devcontainer/Dockerfile",
"description": "We expose port `4000` here because that's what Jekyll runs on by default. This will ensure that the Jekyll _inside_ the container can get _outside_ the container, which allows the Codespaces dev container to host it on a web site that you can visit.",
"line": 55
}
]
}

0 comments on commit c8dd87e

Please sign in to comment.