From a0740c12fb9f95ce6a9aecea2e087911658e9384 Mon Sep 17 00:00:00 2001 From: Cadu Ribeiro Date: Fri, 29 Sep 2023 17:11:29 -0300 Subject: [PATCH] Add devcontainers to the project --- .devcontainer/Dockerfile | 34 +++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 40 ++++++++++++++++++++++++++++++++ .devcontainer/onCreateCommand.sh | 9 +++++++ .devcontainer/welcome.txt | 4 ++++ .ruby-version | 2 +- .tool-versions | 1 + bin/dev | 3 +++ 7 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/onCreateCommand.sh create mode 100644 .devcontainer/welcome.txt create mode 100644 .tool-versions create mode 100755 bin/dev diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d38c82e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d824d13 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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 + } + } +} \ No newline at end of file diff --git a/.devcontainer/onCreateCommand.sh b/.devcontainer/onCreateCommand.sh new file mode 100755 index 0000000..84ffa59 --- /dev/null +++ b/.devcontainer/onCreateCommand.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +echo "Updating RubyGems..." +gem update --system -N + +echo "Installing dependencies..." +bundle + +echo "Done!" \ No newline at end of file diff --git a/.devcontainer/welcome.txt b/.devcontainer/welcome.txt new file mode 100644 index 0000000..5e0f256 --- /dev/null +++ b/.devcontainer/welcome.txt @@ -0,0 +1,4 @@ +👋 Welcome to "Blog"! + +🛠️ Your environment is fully setup with all the required software. + diff --git a/.ruby-version b/.ruby-version index 59aa62c..743af5e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.4.5 +2.6.8 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..63e7200 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +ruby 2.6.8 diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..100ebe6 --- /dev/null +++ b/bin/dev @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +exec bundle exec jekyll serve --config _config.yml,_config-dev.yml