Skip to content

Commit a0740c1

Browse files
committed
Add devcontainers to the project
1 parent c8448a9 commit a0740c1

File tree

7 files changed

+92
-1
lines changed

7 files changed

+92
-1
lines changed

.devcontainer/Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ARG DEBIAN_FRONTEND=noninteractive
2+
ARG VARIANT=bullseye
3+
4+
FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT}
5+
6+
RUN apt-get update && \
7+
apt-get -y install --no-install-recommends \
8+
build-essential gnupg2 tar git zsh libssl-dev zlib1g-dev libyaml-dev curl libreadline-dev \
9+
postgresql-client libpq-dev \
10+
imagemagick libjpeg-dev libpng-dev libtiff-dev libwebp-dev libvips \
11+
tzdata \
12+
tmux \
13+
vim
14+
15+
# Install rbenv and ruby
16+
USER vscode
17+
18+
ARG RUBY_VERSION="2.6.8"
19+
RUN git clone https://github.com/rbenv/rbenv.git /home/vscode/.rbenv \
20+
&& echo '[ -f "/home/vscode/.rbenv/bin/rbenv" ] && eval "$(rbenv init - bash)" # rbenv' >> /home/vscode/.zshrc \
21+
&& echo '[ -f "/home/vscode/.rbenv/bin/rbenv" ] && eval "$(rbenv init - bash)" # rbenv' >> /home/vscode/.bashrc \
22+
&& echo 'export PATH="/home/vscode/.rbenv/bin:$PATH"' >> /home/vscode/.zshrc \
23+
&& echo 'export PATH="/home/vscode/.rbenv/bin:$PATH"' >> /home/vscode/.bashrc \
24+
&& mkdir -p /home/vscode/.rbenv/versions \
25+
&& mkdir -p /home/vscode/.rbenv/plugins \
26+
&& git clone https://github.com/rbenv/ruby-build.git /home/vscode/.rbenv/plugins/ruby-build
27+
28+
ENV PATH "/home/vscode/.rbenv/bin/:HOME/.rbenv/shims/:$PATH"
29+
30+
RUN rbenv install $RUBY_VERSION && \
31+
rbenv global $RUBY_VERSION && \
32+
rbenv versions
33+
34+
COPY .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

.devcontainer/devcontainer.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres
3+
{
4+
"name": "Blog DevContainer",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"context": ".."
8+
},
9+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
10+
"features": {
11+
"ghcr.io/devcontainers/features/node:1": {
12+
"version": "9"
13+
}
14+
},
15+
"remoteEnv": {
16+
"GIT_EDITOR": "code --wait"
17+
},
18+
"onCreateCommand": ".devcontainer/onCreateCommand.sh",
19+
"customizations": {
20+
"vscode": {
21+
// Set *default* container specific settings.json values on container create.
22+
"extensions": [
23+
"GitHub.github-vscode-theme",
24+
"eamodio.gitlens",
25+
],
26+
"rubyLsp.enableExperimentalFeatures": true
27+
}
28+
},
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
"forwardPorts": [
31+
4000
32+
],
33+
"portsAttributes": {
34+
"4000": {
35+
"label": "web",
36+
"onAutoForward": "notify",
37+
"requireLocalPort": true
38+
}
39+
}
40+
}

.devcontainer/onCreateCommand.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Updating RubyGems..."
4+
gem update --system -N
5+
6+
echo "Installing dependencies..."
7+
bundle
8+
9+
echo "Done!"

.devcontainer/welcome.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
👋 Welcome to "Blog"!
2+
3+
🛠️ Your environment is fully setup with all the required software.
4+

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.5
1+
2.6.8

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby 2.6.8

bin/dev

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env sh
2+
3+
exec bundle exec jekyll serve --config _config.yml,_config-dev.yml

0 commit comments

Comments
 (0)