feat: switch docker dev from webpack to vite (#10322)

# Pull Request Template

## Description

- Fix docker development 
- Switch from webpack to vite 

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [x] Breaking change (fix or feature that would cause existing
functionality not to work as expected)

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
This commit is contained in:
Vishnu Narayanan
2024-10-22 14:40:30 +05:30
committed by GitHub
parent 3fe771df6f
commit 35a1dcce43
3 changed files with 36 additions and 11 deletions

View File

@@ -30,14 +30,14 @@ services:
depends_on:
- postgres
- redis
- webpack
- vite
- mailhog
- sidekiq
ports:
- 3000:3000
env_file: .env
environment:
- WEBPACKER_DEV_SERVER_HOST=webpack
- VITE_DEV_SERVER_HOST=vite
- NODE_ENV=development
- RAILS_ENV=development
entrypoint: docker/entrypoints/rails.sh
@@ -61,27 +61,26 @@ services:
- RAILS_ENV=development
command: ["bundle", "exec", "sidekiq", "-C", "config/sidekiq.yml"]
webpack:
vite:
<<: *base
build:
context: .
dockerfile: ./docker/dockerfiles/webpack.Dockerfile
image: chatwoot-webpack:development
dockerfile: ./docker/dockerfiles/vite.Dockerfile
image: chatwoot-vite:development
volumes:
- ./:/app:delegated
- node_modules:/app/node_modules # Node modules shared across containers
- node_modules:/app/node_modules
- packs:/app/public/packs
- cache:/app/tmp/cache
- bundle:/usr/local/bundle
ports:
- "3035" # Webpack dev server
- "5173:5173" # Vite dev server
environment:
- WEBPACKER_DEV_SERVER_HOST=0.0.0.0
- VITE_DEV_SERVER_HOST=0.0.0.0
- NODE_ENV=development
- NODE_OPTIONS=--openssl-legacy-provider
- RAILS_ENV=development
entrypoint: docker/entrypoints/webpack.sh
command: bin/webpack-dev-server
entrypoint: docker/entrypoints/vite.sh
command: pnpm run dev
postgres:
image: postgres:12

View File

@@ -0,0 +1,6 @@
FROM chatwoot:development
RUN chmod +x docker/entrypoints/vite.sh
EXPOSE 5173
CMD ["pnpm", "run", "dev"]

View File

@@ -0,0 +1,20 @@
#!/bin/sh
set -e
rm -rf /app/tmp/pids/server.pid
rm -rf /app/tmp/cache/*
pnpm install --frozen-lockfile
echo "Waiting for pnpm and bundle integrity to match lockfiles...."
PNPM="pnpm list --json | grep -q 'Missing dependencies'"
BUNDLE="bundle check"
until ! $PNPM && $BUNDLE
do
sleep 2;
done
echo "Ready to run Vite development server."
exec "$@"