I am new to docker and attempting to port an app over to it. Essentially, on startup, the app needs to perform some environment dependent work which I have encapsulated in a script.
My app looks like
Dockerfile
scripts/run.sh
build-development/stuff
build-production/stuff
Here is my Dockerfile:
FROM nginx
RUN chmod +x scripts/run.sh
CMD ["scripts/run.sh", APP_ENV]
EXPOSE 80
and here is scripts/run.sh:
#!/bin/bash
mkdir dist
chmod -R 777 dist
if [ $1 == "development" ]
then
cp -R build-development/. /usr/share/nginx/html
fi
if [ $1 == "stage" ]
then
cp -R build-production/. /usr/share/nginx/html
sed -i 's/production/stage/g' dist/index.html
fi
if [ $1 == "production" ]
then
cp -R build-production/. /usr/share/nginx/html
fi
The idea is that I will run the image like:
docker run -e APP_ENV=development app-name
and it will be fed into the script, which will copy the correct files.
Unfortunately, I never get to run the image because during the build step:
docker build -t app-name .
I get errors about
scripts/run.sh not being a file or directory
I don't understand why I am getting this error, I guess it is from naive misunderstanding on my part. What am I doing wrong and how can I make my project work?
Thanks in advance.