mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 02:57:57 +00:00 
			
		
		
		
	chore: Support Github Codespaces (#2510)
Note: Update the ruby version 2.7.3. For production Linux VM, install 2.7.3 and follow the upgrade steps as shown in https://www.chatwoot.com/docs/self-hosted/deployment/linux-vm#upgrading-to-a-newer-version-of-chatwoot
This commit is contained in:
		| @@ -7,7 +7,7 @@ defaults: &defaults | |||||||
|   working_directory: ~/build |   working_directory: ~/build | ||||||
|   docker: |   docker: | ||||||
|     # specify the version you desire here |     # specify the version you desire here | ||||||
|     - image: circleci/ruby:2.7.2-node-browsers |     - image: circleci/ruby:2.7.3-node-browsers | ||||||
|  |  | ||||||
|     # Specify service dependencies here if necessary |     # Specify service dependencies here if necessary | ||||||
|     # CircleCI maintains a library of pre-built images |     # CircleCI maintains a library of pre-built images | ||||||
|   | |||||||
| @@ -1,51 +1,11 @@ | |||||||
| # pre-build stage | # The below image is created out of the Dockerfile.base | ||||||
| ARG VARIANT=2.7 | # It has the dependencies already installed so that codespace will boot up fast | ||||||
| FROM mcr.microsoft.com/vscode/devcontainers/ruby:${VARIANT} | FROM ghcr.io/sojan-official/chatwoot_codespace:latest | ||||||
|  |  | ||||||
| # 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 <your-package-here>" 2>&1 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| # Do the set up required for chatwoot app  | # Do the set up required for chatwoot app  | ||||||
| WORKDIR /workspace | WORKDIR /workspace | ||||||
| COPY . /workspace | COPY . /workspace | ||||||
|  | RUN yarn | ||||||
|  |  | ||||||
| # TODO: figure out installing rvm |  | ||||||
| # RUN rvm install |  | ||||||
| COPY Gemfile Gemfile.lock ./ | COPY Gemfile Gemfile.lock ./ | ||||||
| RUN gem install bundler | RUN gem install bundler && bundle install | ||||||
| RUN bundle install |  | ||||||
| COPY package.json yarn.lock ./ |  | ||||||
| RUN yarn install |  | ||||||
							
								
								
									
										45
									
								
								.devcontainer/Dockerfile.base
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								.devcontainer/Dockerfile.base
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | |||||||
|  | # 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 | ||||||
|  |  | ||||||
|  | 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 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # Install overmind | ||||||
|  | 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  | ||||||
|  |  | ||||||
|  | # Do the set up required for chatwoot app  | ||||||
|  | WORKDIR /workspace | ||||||
|  | COPY . /workspace | ||||||
|  | RUN yarn | ||||||
|  |  | ||||||
|  | COPY Gemfile Gemfile.lock ./ | ||||||
|  | RUN gem install bundler && bundle install | ||||||
|  |  | ||||||
| @@ -30,4 +30,12 @@ | |||||||
|   // Use 'postCreateCommand' to run commands after the container is created. |   // Use 'postCreateCommand' to run commands after the container is created. | ||||||
|   // #TODO: can we move logic of copy env file into dockerfile ? |   // #TODO: can we move logic of copy env file into dockerfile ? | ||||||
|   "postCreateCommand": "cp .env.example .env", |   "postCreateCommand": "cp .env.example .env", | ||||||
|  |   "portsAttributes": { | ||||||
|  |     "3000": { | ||||||
|  |       "label": "Rails Server" | ||||||
|  |     }, | ||||||
|  |     "8025": { | ||||||
|  |       "label": "Mailhog UI" | ||||||
|  |     } | ||||||
|  |   }, | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								.github/workflows/publish_codespace_image.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.github/workflows/publish_codespace_image.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | name: Publish Codespace Base Image | ||||||
|  |  | ||||||
|  | on: | ||||||
|  |   workflow_dispatch: | ||||||
|  |  | ||||||
|  | jobs: | ||||||
|  |   publish-code-space-image: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |  | ||||||
|  |     steps: | ||||||
|  |     - uses: actions/checkout@v2 | ||||||
|  |  | ||||||
|  |     - name: Login to GitHub Container Registry | ||||||
|  |       uses: docker/login-action@v1 | ||||||
|  |       with: | ||||||
|  |         registry: ghcr.io | ||||||
|  |         username: ${{ github.actor }} | ||||||
|  |         password: ${{ secrets.GITHUB_TOKEN }} | ||||||
|  |  | ||||||
|  |     - name: Build the Codespace Base Image | ||||||
|  |       run: | | ||||||
|  |         docker build . -t ghcr.io/chatwoot/chatwoot_codespace:latest -f .devcontainer/Dockerfile.base  | ||||||
|  |         docker push ghcr.io/chatwoot/chatwoot_codespace:latest | ||||||
| @@ -1 +1 @@ | |||||||
| 2.7.2 | 2.7.3 | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| source 'https://rubygems.org' | source 'https://rubygems.org' | ||||||
|  |  | ||||||
| ruby '2.7.2' | ruby '2.7.3' | ||||||
|  |  | ||||||
| ##-- base gems for rails --## | ##-- base gems for rails --## | ||||||
| gem 'rack-cors', require: 'rack/cors' | gem 'rack-cors', require: 'rack/cors' | ||||||
|   | |||||||
| @@ -704,7 +704,7 @@ DEPENDENCIES | |||||||
|   wisper (= 2.0.0) |   wisper (= 2.0.0) | ||||||
|  |  | ||||||
| RUBY VERSION | RUBY VERSION | ||||||
|    ruby 2.7.2p137 |    ruby 2.7.3p183 | ||||||
|  |  | ||||||
| BUNDLED WITH | BUNDLED WITH | ||||||
|    2.1.4 |    2.1.4 | ||||||
|   | |||||||
| @@ -16,10 +16,10 @@ KillMode=mixed | |||||||
| StandardInput=null | StandardInput=null | ||||||
| SyslogIdentifier=%p | SyslogIdentifier=%p | ||||||
|  |  | ||||||
| Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.2/bin:/home/chatwoot/.rvm/gems/ruby-2.7.2@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.2/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" | Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3/bin:/home/chatwoot/.rvm/gems/ruby-2.7.3@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.3/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" | ||||||
| Environment="PORT=3000" | Environment="PORT=3000" | ||||||
| Environment="RAILS_ENV=production" | Environment="RAILS_ENV=production" | ||||||
| Environment="NODE_ENV=production" | Environment="NODE_ENV=production" | ||||||
| Environment="RAILS_LOG_TO_STDOUT=true" | Environment="RAILS_LOG_TO_STDOUT=true" | ||||||
| Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.2" | Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.3" | ||||||
| Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.2:/home/chatwoot/.rvm/gems/ruby-2.7.2@global" | Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3:/home/chatwoot/.rvm/gems/ruby-2.7.3@global" | ||||||
|   | |||||||
| @@ -16,10 +16,10 @@ KillMode=mixed | |||||||
| StandardInput=null | StandardInput=null | ||||||
| SyslogIdentifier=%p | SyslogIdentifier=%p | ||||||
|  |  | ||||||
| Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.2/bin:/home/chatwoot/.rvm/gems/ruby-2.7.2@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.2/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" | Environment="PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3/bin:/home/chatwoot/.rvm/gems/ruby-2.7.3@global/bin:/home/chatwoot/.rvm/rubies/ruby-2.7.3/bin:/home/chatwoot/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/chatwoot/.rvm/bin:/home/chatwoot/.rvm/bin" | ||||||
| Environment="PORT=3000" | Environment="PORT=3000" | ||||||
| Environment="RAILS_ENV=production" | Environment="RAILS_ENV=production" | ||||||
| Environment="NODE_ENV=production" | Environment="NODE_ENV=production" | ||||||
| Environment="RAILS_LOG_TO_STDOUT=true" | Environment="RAILS_LOG_TO_STDOUT=true" | ||||||
| Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.2" | Environment="GEM_HOME=/home/chatwoot/.rvm/gems/ruby-2.7.3" | ||||||
| Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.2:/home/chatwoot/.rvm/gems/ruby-2.7.2@global" | Environment="GEM_PATH=/home/chatwoot/.rvm/gems/ruby-2.7.3:/home/chatwoot/.rvm/gems/ruby-2.7.3@global" | ||||||
|   | |||||||
| @@ -43,8 +43,8 @@ RAILS_ENV=production | |||||||
| sudo -i -u chatwoot << EOF | sudo -i -u chatwoot << EOF | ||||||
| rvm --version | rvm --version | ||||||
| rvm autolibs disable | rvm autolibs disable | ||||||
| rvm install "ruby-2.7.2" | rvm install "ruby-2.7.3" | ||||||
| rvm use 2.7.2 --default | rvm use 2.7.3 --default | ||||||
|  |  | ||||||
| git clone https://github.com/chatwoot/chatwoot.git | git clone https://github.com/chatwoot/chatwoot.git | ||||||
| cd chatwoot | cd chatwoot | ||||||
|   | |||||||
| @@ -50,8 +50,8 @@ RAILS_ENV=production | |||||||
| sudo -i -u chatwoot << EOF | sudo -i -u chatwoot << EOF | ||||||
| rvm --version | rvm --version | ||||||
| rvm autolibs disable | rvm autolibs disable | ||||||
| rvm install "ruby-2.7.2" | rvm install "ruby-2.7.3" | ||||||
| rvm use 2.7.2 --default | rvm use 2.7.3 --default | ||||||
|  |  | ||||||
| git clone https://github.com/chatwoot/chatwoot.git | git clone https://github.com/chatwoot/chatwoot.git | ||||||
| cd chatwoot | cd chatwoot | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| # pre-build stage | # pre-build stage | ||||||
| FROM ruby:2.7.2-alpine AS pre-builder | FROM ruby:2.7.3-alpine AS pre-builder | ||||||
|  |  | ||||||
| # ARG default to production settings | # ARG default to production settings | ||||||
| # For development docker-compose file overrides ARGS | # For development docker-compose file overrides ARGS | ||||||
| @@ -51,7 +51,7 @@ RUN if [ "$RAILS_ENV" = "production" ]; then \ | |||||||
|   fi |   fi | ||||||
|  |  | ||||||
| # final build stage | # final build stage | ||||||
| FROM ruby:2.7.2-alpine | FROM ruby:2.7.3-alpine | ||||||
|  |  | ||||||
| ARG BUNDLE_WITHOUT="development:test" | ARG BUNDLE_WITHOUT="development:test" | ||||||
| ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} | ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sojan Jose
					Sojan Jose