fix: pnpm in vite docker (#10344)

- Fix pnpm path in vite docker
- Remove webpack files
- fFx vite server port
This commit is contained in:
Vishnu Narayanan
2024-10-29 15:16:10 +05:30
committed by GitHub
parent 0689f59a05
commit 55dfd7db50
6 changed files with 13 additions and 44 deletions

View File

@@ -74,13 +74,13 @@ services:
- cache:/app/tmp/cache - cache:/app/tmp/cache
- bundle:/usr/local/bundle - bundle:/usr/local/bundle
ports: ports:
- "5173:5173" # Vite dev server - "3036:3036" # Vite dev server
environment: environment:
- VITE_DEV_SERVER_HOST=0.0.0.0 - VITE_DEV_SERVER_HOST=0.0.0.0
- NODE_ENV=development - NODE_ENV=development
- RAILS_ENV=development - RAILS_ENV=development
entrypoint: docker/entrypoints/vite.sh entrypoint: docker/entrypoints/vite.sh
command: pnpm run dev command: bin/vite dev
postgres: postgres:
image: postgres:12 image: postgres:12

View File

@@ -5,7 +5,7 @@ FROM ruby:3.3.3-alpine3.19 AS pre-builder
# For development docker-compose file overrides ARGS # For development docker-compose file overrides ARGS
ARG BUNDLE_WITHOUT="development:test" ARG BUNDLE_WITHOUT="development:test"
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
ENV BUNDLER_VERSION=2.1.2 ENV BUNDLER_VERSION=2.5.11
ARG RAILS_SERVE_STATIC_FILES=true ARG RAILS_SERVE_STATIC_FILES=true
ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES} ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES}
@@ -89,7 +89,7 @@ FROM ruby:3.3.3-alpine3.19
ARG BUNDLE_WITHOUT="development:test" ARG BUNDLE_WITHOUT="development:test"
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT} ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
ENV BUNDLER_VERSION=2.1.2 ENV BUNDLER_VERSION=2.5.11
ARG EXECJS_RUNTIME="Disabled" ARG EXECJS_RUNTIME="Disabled"
ENV EXECJS_RUNTIME ${EXECJS_RUNTIME} ENV EXECJS_RUNTIME ${EXECJS_RUNTIME}
@@ -115,7 +115,7 @@ RUN apk update && apk add --no-cache \
&& gem install bundler && gem install bundler
RUN if [ "$RAILS_ENV" != "production" ]; then \ RUN if [ "$RAILS_ENV" != "production" ]; then \
apk add --no-cache nodejs-current; \ apk add --no-cache nodejs=20.15.1-r0; \
# Install pnpm and configure environment # Install pnpm and configure environment
wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh - \ wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh - \
&& source /root/.shrc \ && source /root/.shrc \

View File

@@ -1,6 +1,9 @@
FROM chatwoot:development FROM chatwoot:development
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN chmod +x docker/entrypoints/vite.sh RUN chmod +x docker/entrypoints/vite.sh
EXPOSE 5173 EXPOSE 3036
CMD ["pnpm", "run", "dev"] CMD ["bin/vite", "dev"]

View File

@@ -1,6 +0,0 @@
FROM chatwoot:development
RUN chmod +x docker/entrypoints/webpack.sh
EXPOSE 3035
CMD ["bin/webpack-dev-server"]

14
docker/entrypoints/vite.sh Normal file → Executable file
View File

@@ -1,19 +1,11 @@
#!/bin/sh #!/bin/sh
set -e set -x
rm -rf /app/tmp/pids/server.pid rm -rf /app/tmp/pids/server.pid
rm -rf /app/tmp/cache/* rm -rf /app/tmp/cache/*
pnpm install --frozen-lockfile pnpm store prune
pnpm install
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." echo "Ready to run Vite development server."

View File

@@ -1,20 +0,0 @@
#!/bin/sh
set -e
rm -rf /app/tmp/pids/server.pid
rm -rf /app/tmp/cache/*
yarn install --check-files
echo "Waiting for yarn and bundle integrity to match lockfiles...."
YARN="yarn check --integrity"
BUNDLE="bundle check"
until $YARN && $BUNDLE
do
sleep 2;
done
echo "Ready to run webpack development server."
exec "$@"