Reputation: 1076
My project, written in Node.js, runs a Python file that needs to be built. Previously, I have used a script to set up the project when pulled from GitHub. I'd like to use Docker instead but am having issues when running multiple FROMs. My understanding is that FROM creates a new image and it is for this reason that my project build fails. What is the solution to this?
Original Shell Script
yarn
git clone https://github.com/<directory>
mv <directory> <new_name>
cd <directory>
virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt
Attempted Dockerfile
FROM python:3.6
RUN mkdir -p /usr/src/app
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN git clone https://github.com/<directory>
RUN mv /usr/src/app/<directory> /usr/src/app/<new_name>
RUN pip3 install -r <new_name>/requirements.txt
FROM node:11
WORKDIR /usr/src/app
RUN npm install --production
EXPOSE 3000
ENTRYPOINT npm start
Upvotes: 3
Views: 1891
Reputation: 3346
You have to use any one image and install other application into that image. So your dockerfile may look like:
FROM node:11
RUN mkdir -p /usr/src/app
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN git clone https://github.com/<directory>
RUN mv /usr/src/app/<directory> /usr/src/app/<new_name>
RUN Command to install python 3.6 and pip3
RUN pip3 install -r <new_name>/requirements.txt
WORKDIR /usr/src/app
RUN npm install --production
EXPOSE 3000
ENTRYPOINT npm start
You can refer this sample dockefile.
Upvotes: 2