Docker Community Forums

Share and learn in the Docker community.

Trying to get webpacker working in Docker


#1

Ultimately, this is so that I can use the react-rails gem. I was able to do the gem installs, everything went fine there. I have yarn and nodejs and nodejs-rpm installed. However, for the life of me, I cannot get webpacker to run. I’ve tried a few configurations. For example:

Dockerfile:

FROM ruby:alpine
ARG precompileassets

RUN apk add --update build-base postgresql-dev tzdata graphviz git openssh yarn nodejs nodejs-npm
RUN gem install rails -v ‘5.2.0’

ENV LANG en_GB.UTF-8
RUN apk add --update ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family && rm -rf /var/cache/apk/*

WORKDIR /app
ADD Gemfile Gemfile.lock /app/
RUN bundle install
ADD . .
CMD [“puma”]

docker-compose.yml:
version: ‘3.6’
services:
web:
build: .
volumes:
- ./:/app
working_dir: /app
command: puma
ports:
- 3000:3000
depends_on:
- db
links:
- db
- webpacker
environment:
DATABASE_URL: postgres://postgres@db
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0

db:
image: postgres:10.3-alpine

webpacker:
build: .
command: ./bin/webpack-dev-server
volumes:
- .:/opt/dockerrailsdemo:cached
ports:
- 3035:3035
environment:
WEBPACKER_DEV_SERVER_HOST: 0.0.0.0

I’ve tried without volumes, I’ve tried specifying different volumes, I’ve specified images, nothing works. Here’s the error I usually see:

/app/node_modules/.bin/webpack-dev-server: line 1: XSym: not found
webpacker_1 | /app/node_modules/.bin/webpack-dev-server: line 2: 0047: not found
webpacker_1 | /app/node_modules/.bin/webpack-dev-server: line 3: baebe48db4509e117ed95eca45abdd2e: not found
webpacker_1 | /app/node_modules/.bin/webpack-dev-server: line 4: …/webpack-dev-server/bin/webpack-dev-server.js: not found

Any suggestions?