Skip to content

Commit

Permalink
Add devcontainers to the project
Browse files Browse the repository at this point in the history
  • Loading branch information
duduribeiro committed Sep 29, 2023
1 parent c8448a9 commit a0740c1
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG DEBIAN_FRONTEND=noninteractive
ARG VARIANT=bullseye

FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT}

RUN apt-get update && \
apt-get -y install --no-install-recommends \
build-essential gnupg2 tar git zsh libssl-dev zlib1g-dev libyaml-dev curl libreadline-dev \
postgresql-client libpq-dev \
imagemagick libjpeg-dev libpng-dev libtiff-dev libwebp-dev libvips \
tzdata \
tmux \
vim

# Install rbenv and ruby
USER vscode

ARG RUBY_VERSION="2.6.8"
RUN git clone https://github.com/rbenv/rbenv.git /home/vscode/.rbenv \
&& echo '[ -f "/home/vscode/.rbenv/bin/rbenv" ] && eval "$(rbenv init - bash)" # rbenv' >> /home/vscode/.zshrc \
&& echo '[ -f "/home/vscode/.rbenv/bin/rbenv" ] && eval "$(rbenv init - bash)" # rbenv' >> /home/vscode/.bashrc \
&& echo 'export PATH="/home/vscode/.rbenv/bin:$PATH"' >> /home/vscode/.zshrc \
&& echo 'export PATH="/home/vscode/.rbenv/bin:$PATH"' >> /home/vscode/.bashrc \
&& mkdir -p /home/vscode/.rbenv/versions \
&& mkdir -p /home/vscode/.rbenv/plugins \
&& git clone https://github.com/rbenv/ruby-build.git /home/vscode/.rbenv/plugins/ruby-build

ENV PATH "/home/vscode/.rbenv/bin/:HOME/.rbenv/shims/:$PATH"

RUN rbenv install $RUBY_VERSION && \
rbenv global $RUBY_VERSION && \
rbenv versions

COPY .devcontainer/welcome.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres
{
"name": "Blog DevContainer",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "9"
}
},
"remoteEnv": {
"GIT_EDITOR": "code --wait"
},
"onCreateCommand": ".devcontainer/onCreateCommand.sh",
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"extensions": [
"GitHub.github-vscode-theme",
"eamodio.gitlens",
],
"rubyLsp.enableExperimentalFeatures": true
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
4000
],
"portsAttributes": {
"4000": {
"label": "web",
"onAutoForward": "notify",
"requireLocalPort": true
}
}
}
9 changes: 9 additions & 0 deletions .devcontainer/onCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

echo "Updating RubyGems..."
gem update --system -N

echo "Installing dependencies..."
bundle

echo "Done!"
4 changes: 4 additions & 0 deletions .devcontainer/welcome.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
👋 Welcome to "Blog"!

🛠️ Your environment is fully setup with all the required software.

2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.5
2.6.8
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 2.6.8
3 changes: 3 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

exec bundle exec jekyll serve --config _config.yml,_config-dev.yml

0 comments on commit a0740c1

Please sign in to comment.