For the last 3 years this blog was written using Jekyll which has a series of requirements such as Ruby that I don’t want to keep installing or maintaining on my PC. So I created this Developer Container for those who want to use Jekyll from an isolated container.
Let’s check the container definition:
devcontainer.json file
This file configures the remote container with the specified extensions
1{
2 "name": "Jekyll",
3 "dockerFile": "Dockerfile",
4
5 // Use 'settings' to set *default* container specific settings.json values on container create.
6 // You can edit these settings after create using File > Preferences > Settings > Remote.
7 "settings": {
8 "terminal.integrated.shell.linux": "/bin/bash"
9 },
10
11 // Use 'appPort' to create a container with published ports. If the port isn't working, be sure
12 // your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
13 // "appPort": ["3000:3000"],
14
15 // Uncomment the next line to run commands after the container is created.
16 // "postCreateCommand": "cd ${input:projectName} && bundle install",
17
18 // Uncomment the next line to use a non-root user. On Linux, this will prevent
19 // new files getting created as root, but you may need to update the USER_UID
20 // and USER_GID in .devcontainer/Dockerfile to match your user if not 1000.
21 // "runArgs": [ "-u", "vscode" ],
22
23 // Add the IDs of extensions you want installed when the container is created in the array below.
24 "extensions": []
25}
Dockerfile
This is the Dockerfile with all the tooling for the Jekyll environment.
1FROM debian:latest
2
3# Avoid warnings by switching to noninteractive
4ENV DEBIAN_FRONTEND=noninteractive
5
6# This Dockerfile adds a non-root 'vscode' user with sudo access. However, for Linux,
7# this user's GID/UID must match your local user UID/GID to avoid permission issues
8# with bind mounts. Update USER_UID / USER_GID if yours is not 1000. See
9# https://aka.ms/vscode-remote/containers/non-root-user for details.
10ARG USERNAME=vscode
11ARG USER_UID=1000
12ARG USER_GID=$USER_UID
13
14# Configure apt and install packages
15RUN apt-get update \
16 && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
17 #
18 # Install vim, git, process tools, lsb-release
19 && apt-get install -y \
20 git \
21 #
22 # Install ruby
23 && apt-get install -y \
24 make \
25 build-essential \
26 ruby \
27 ruby-dev \
28 #
29 # Install jekyll
30 && gem install \
31 bundler \
32 jekyll \
33 #
34 # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
35 && groupadd --gid $USER_GID $USERNAME \
36 && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
37 # [Optional] Add sudo support for the non-root user
38 && apt-get install -y sudo \
39 && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
40 && chmod 0440 /etc/sudoers.d/$USERNAME \
41 #
42 # Clean up
43 && apt-get autoremove -y \
44 && apt-get clean -y \
45 && rm -rf /var/lib/apt/lists/*
46
47# Switch back to dialog for any ad-hoc use of apt-get
48ENV DEBIAN_FRONTEND=dialog
To learn more about this Remote Container please check here.
If you want to use Developer Conatianers with WSL 2 start here
Hope it helps!
Comments