Home > Back-end >  Copy dockerfile files ADD instruction in superset
Copy dockerfile files ADD instruction in superset

Time:05-14

I have the following DockerFile

FROM apache/superset:pr-19860
RUN pip install elasticsearch-dbapi
RUN superset superset fab create-admin \
               --username admin \
               --firstname Superset \
               --lastname Admin \
               --email [email protected] \
               --password admin

RUN superset superset db upgrade
RUN superset superset load_examples
RUN superset superset init
ADD https://github.com/domsoltel/superset/blob/436efe104938d0ca555bb99c586f3d2675a69a59/config.py /app/superset/
ADD https://github.com/domsoltel/superset/blob/436efe104938d0ca555bb99c586f3d2675a69a59/viz.py /app//superset/

I have to modify the config.py and viz.py file to make it work the way I want it to. These files already exist in the superset container but I need to modify a few variables

If I do docker cp it works perfectly, from my pc to the container it works perfectly but with the dockerfile I get the following error

PermissionError: [Errno 13] Permission denied: '/app/superset/config.py'

I think it might be a permissions problem, how can I fix it?

CodePudding user response:

The superset image is set up to run as the user superset which doesn't have full permissions. So before your change anything, you should switch to root and then back to the superset user when you´re done.

You can see an example at the bottom of the page for the image (under 'How to extend this image'): https://hub.docker.com/r/apache/superset

FROM apache/superset:pr-19860
USER root
RUN pip install elasticsearch-dbapi
RUN superset superset fab create-admin \
               --username admin \
               --firstname Superset \
               --lastname Admin \
               --email [email protected] \
               --password admin

RUN superset superset db upgrade
RUN superset superset load_examples
RUN superset superset init
ADD --chown=superset:superset https://raw.githubusercontent.com/domsoltel/superset/436efe104938d0ca555bb99c586f3d2675a69a59/config.py /app/superset/
ADD --chown=superset:superset https://raw.githubusercontent.com/domsoltel/superset/436efe104938d0ca555bb99c586f3d2675a69a59/viz.py /app/superset/
RUN chmod 644 /app/superset/config.py && chmod 644 /app/superset/viz.py
USER superset

I've also changed the URLs of the files to the raw versions. With the URLs you had, you would add HTML versions of the files which isn't going to work.

CodePudding user response:

Since you're using docker-compose; then use volumes to map those files

you_service:
  image: .....
  ....
  ....
  volumes:
    - /home/config.py:/app/superset/config.py
    - /home/viz.py:/app/superset/viz.py

Note that volumes must be an absolute path to work with mapping files (unlike mapping directories)

Another note: if the file is in-use by the container; then you'll get the permission error anyway!

  • Related