I’m new to Docker and currently and I’m working on the dokernizing some apps.
Structure of project :
-PlayProject
-------app
----------controllers
----------models
----------views
-------ci
-------conf
-------project
-------public
----------css
----------js
----------img
----------fonts
-------sbt-cache
-------src
-------target
-------front
------------header (npm folder)
------------footer (npm folder)
-------Dockerfile
----*
The project is developed with PlayFramework (with sbt as a build tool) on Backend and Reactjs on front. The front is constritued from gtwo modules (header and footer).
On my dockerfile I need to run build the modules front (run ‘npm run build’ commands in both folders header and footer) to update the public folder before conternizing
My Dockerfile :
FROM openjdk:8
ENV HEADER front/header
ENV FOOTER front/footer
ENV PROJECT_HOME /usr/src
ENV SBT_VERSION 1.2.1
#install node
RUN
curl -sL https://deb.nodesource.com/setup_4.x | bash &&
# and install node
apt-get update &&
apt-get install nodejs &&
# confirm that it was successful
node -v &&
# npm installs automatically
npm -v
WORKDIR $HEADER/
RUN
echo $(ls -1 $HEADER/) &&
npm cache clean &&
npm i &&
npm run build
WORKDIR $FOOTER/
RUN
echo $(ls -1 $FOOTER/) &&
npm cache clean &&
npm i &&
npm run build
RUN mkdir -p $PROJECT_HOME/sbt $PROJECT_HOME/app
WORKDIR $PROJECT_HOME/sbt
# Install curl
RUN
apt-get update &&
apt-get -y install curl &&
apt-get -y install vim
# Install sbt
RUN
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb &&
dpkg -i sbt-$SBT_VERSION.deb &&
rm sbt-$SBT_VERSION.deb &&
apt-get update &&
apt-get -y install sbt
COPY . $PROJECT_HOME/app
WORKDIR $PROJECT_HOME/app
EXPOSE 9000
The issue is that I cannot localize the front folders and run my npm commands. what do you think ?
2
Answers
It looks like you’re not actually sending your local source to the Docker container, so there’s nothing to build.
Try adding a line like
COPY . .
before you switch the WORKDIR.You didn’t set an absolute path to your first WORKDIR instruction :
quoted from here
Maybe you want to replace your first WORKDIR like this :