How to make base BE FE env with Docker


#1

Hi I’m trying to make a base env with frontend and backend with Docker but i get error when I try:
docker-compose up or docker-compose up --build

the error is:

No prebuilt Ninja, building Ninja now
env: can't execute 'python': No such file or directory

repo here -> https://github.com/lorenzo-pomili/docker_be_fe_env

can someone help me to figure out what happens? (is my first env with docker so I don’t know what to search ^^")


#2

I got the same error.

The main issue is that BuckleScript on install-time have prebuild binaries that use glibc in order to build ninja, and often some docker images like alpine don’t have glibc and relie on musl lib.

I solve this using the docker image node:12 and later use the alpine that goes into prod.

  
# This stage installs our modules
FROM node:12
WORKDIR /app
COPY . ./
# Don't install dev dependencies
RUN yarn install --prod
RUN yarn re:build

# Multi-stage build: Use this as a nice small base image
FROM mhart/alpine-node:slim-12
WORKDIR /app
# Copy files from build image 
COPY --from=0 /app .
COPY . .
RUN ls -a 
RUN ls -a src/
CMD ["node", "src/Server.bs.js"]

#3

it seems work (I have some other problems but I’ll fix tomorrow^^"), thanks @davesnx :slight_smile:


#4

ok, I was wrong :frowning: , I was trying to let it work with npm commands instead of yarn because RUN yarn re:build give me this error:

error Command "re:build" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: Service 'server' failed to build: The command '/bin/sh -c yarn re:build' returned a non-zero code: 1

and I don’t know very well yarn but now I got an error on build it did not find bsb :frowning: