diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..b1bef7b28 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,51 @@ +# pre-build stage +ARG VARIANT=2.7 +FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT} + +# 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 \ + && chmod -R $USER_UID:$USER_GID /home/vscode; \ + fi + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + + +# tmux is for overmind +# TODO : install foreman in future +# packages: postgresql-server-dev-all +# may be postgres in same machine + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends \ + libssl-dev \ + tar \ + tzdata \ + postgresql-client \ + yarn \ + git \ + imagemagick \ + tmux \ + zsh + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 + + +# Do the set up required for chatwoot app +WORKDIR /workspace +COPY . /workspace + +# TODO: figure out installing rvm +# RUN rvm install +COPY Gemfile Gemfile.lock ./ +RUN gem install bundler +RUN bundle install +COPY package.json yarn.lock ./ +RUN yarn install diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..5f878e5e0 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "Chatwoot Development Codespace", + "service": "app", + "dockerComposeFile": "docker-compose.yml", + + "settings": { + "terminal.integrated.shell.linux": "/bin/zsh" + }, + + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "rebornix.Ruby", + "misogi.ruby-rubocop", + "wingrunr21.vscode-ruby" + ], + + + // TODO: figure whether we can get all this ports work properly + + // 3000 rails + // 3035 webpacker + // 5432 postgres + // 6379 redis + // 1025,8025 mailhog + "forwardPorts": [5432, 6379, 1025, 8025], + //your application may need to listen on all interfaces (0.0.0.0) not just localhost for it to be available externally. Defaults to [] + "appPort": [3000, 3035], + + // Use 'postCreateCommand' to run commands after the container is created. + // #TODO: can we move logic of copy env file into dockerfile ? + "postCreateCommand": "cp .env.example .env", +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..6a2ffbea6 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,56 @@ +# 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: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + args: + # Update 'VARIANT' to pick a Ruby version: 2, 2.7, 2.6, 2.5 + VARIANT: 2.7 + # [Choice] Install Node.js + INSTALL_NODE: "true" + NODE_VERSION: "lts/*" + # 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 + + 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 + + db: + image: postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: postgres + POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres + + redis: + image: redis:latest + restart: unless-stopped + network_mode: service:db + volumes: + - redis-data:/data + + mailhog: + restart: unless-stopped + image: mailhog/mailhog + network_mode: service:db + +volumes: + postgres-data: + redis-data: + \ No newline at end of file diff --git a/.env.example b/.env.example index 008195ef7..4fe8ec3c8 100644 --- a/.env.example +++ b/.env.example @@ -133,4 +133,3 @@ USE_INBOX_AVATAR_FOR_BOT=true ## Development Only Config # if you want to use letter_opener for local emails # LETTER_OPENER=true -