From 4958b3e7b62aa4f6dc1c6e281b51d9a666c942ba Mon Sep 17 00:00:00 2001 From: Liam <43280985+LiamAshdown@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:34:23 +0000 Subject: [PATCH] chore: Fix codespaces not booting up (#8264) Fixed an issue where the codespace was not correctly booting up. Fixes #7609 Co-authored-by: Liam Ashdown Co-authored-by: Sojan --- .devcontainer/Dockerfile | 2 +- .devcontainer/Dockerfile.base | 25 +++++++------ .devcontainer/docker-compose.yml | 36 ++++++++++++------- .github/workflows/publish_codespace_image.yml | 3 +- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2418bd621d8ab..3fd4f1a31b388 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,7 +2,7 @@ # It has the dependencies already installed so that codespace will boot up fast FROM ghcr.io/chatwoot/chatwoot_codespace:latest -# Do the set up required for chatwoot app +# Do the set up required for chatwoot app WORKDIR /workspace COPY . /workspace RUN yarn && gem install bundler && bundle install diff --git a/.devcontainer/Dockerfile.base b/.devcontainer/Dockerfile.base index c9e3c8fcf5ca5..fe31dc42e6d00 100644 --- a/.devcontainer/Dockerfile.base +++ b/.devcontainer/Dockerfile.base @@ -1,10 +1,14 @@ -ARG VARIANT=ubuntu-20.04 -FROM mcr.microsoft.com/vscode/devcontainers/base:${VARIANT} +ARG VARIANT + +FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} + +ARG NODE_VERSION +ARG RUBY_VERSION +ARG USER_UID +ARG USER_GID # Update args in docker-compose.yaml to set the UID/GID of the "vscode" user. -ARG USER_UID=1000 -ARG USER_GID=$USER_UID RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \ groupmod --gid $USER_GID vscode \ && usermod --uid $USER_UID --gid $USER_GID vscode \ @@ -27,10 +31,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ tmux \ zsh \ git-flow \ - npm + npm \ + libyaml-dev # Install rbenv and ruby -ARG RUBY_VERSION="3.2.2" RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv \ && echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc \ && echo 'eval "$(rbenv init -)"' >> ~/.bashrc @@ -46,7 +50,7 @@ RUN rbenv install $RUBY_VERSION && \ RUN curl -L https://github.com/DarthSim/overmind/releases/download/v2.1.0/overmind-v2.1.0-linux-amd64.gz > overmind.gz \ && gunzip overmind.gz \ && sudo mv overmind /usr/local/bin \ - && chmod +x /usr/local/bin/overmind + && chmod +x /usr/local/bin/overmind # Install gh @@ -56,7 +60,7 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | s && sudo apt install gh -# Do the set up required for chatwoot app +# Do the set up required for chatwoot app WORKDIR /workspace COPY . /workspace @@ -65,8 +69,7 @@ COPY Gemfile Gemfile.lock ./ RUN gem install bundler && bundle install # set up node js -RUN npm install npm@latest -g && \ - npm install n -g && \ - n latest +RUN npm install n -g && \ + n $NODE_VERSION RUN npm install --global yarn RUN yarn diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 36e4e82141521..17021d1e7538b 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -1,30 +1,41 @@ # https://github.com/microsoft/vscode-dev-containers/blob/master/containers/python-3-postgres/.devcontainer/docker-compose.yml # https://github.com/microsoft/vscode-dev-containers/blob/master/containers/ruby-rails/.devcontainer/devcontainer.json -# +# version: '3' services: - app: + base: + build: + context: .. + dockerfile: .devcontainer/Dockerfile.base + args: + VARIANT: "ubuntu-22.04" + NODE_VERSION: "20.9.0" + RUBY_VERSION: "3.2.2" + # On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000. + USER_UID: "1000" + USER_GID: "1000" + image: base:latest + + app: build: context: .. dockerfile: .devcontainer/Dockerfile args: - # Update 'VARIANT' to pick a Ruby version: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/ruby - VARIANT: 3 - # [Choice] Install Node.js - INSTALL_NODE: "true" - NODE_VERSION: "lts/*" + VARIANT: "ubuntu-22.04" + NODE_VERSION: "20.9.0" + RUBY_VERSION: "3.2.2" # On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000. - USER_UID: 1000 - USER_GID: 1000 + USER_UID: "1000" + USER_GID: "1000" volumes: - ..:/workspace:cached - + # Overrides default command so things don't shut down after the process ends. command: sleep infinity - + # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. network_mode: service:db @@ -49,8 +60,7 @@ services: restart: unless-stopped image: mailhog/mailhog network_mode: service:db - + volumes: postgres-data: redis-data: - \ No newline at end of file diff --git a/.github/workflows/publish_codespace_image.yml b/.github/workflows/publish_codespace_image.yml index d71787eb15ca7..60632d906b603 100644 --- a/.github/workflows/publish_codespace_image.yml +++ b/.github/workflows/publish_codespace_image.yml @@ -19,5 +19,6 @@ jobs: - name: Build the Codespace Base Image run: | - docker build . -t ghcr.io/chatwoot/chatwoot_codespace:latest -f .devcontainer/Dockerfile.base + docker-compose -f .devcontainer/docker-compose.yml build base + docker tag base:latest ghcr.io/chatwoot/chatwoot_codespace:latest docker push ghcr.io/chatwoot/chatwoot_codespace:latest