superset/contrib/docker/Dockerfile
Xiao Hanyu 0a276ff75d Init docker for local development environment. (#4193)
This commit will try to dockerize superset in local development
environment.

The basic design is:
- Enable superset, redis and postgres service instead of using sqlite,
  just want to simulate production environment settings
- Use environment variables to config various app settings. It's easy to
  run and config superset to any environment if we use environment than
  traditional config files
- For local development environment, we just expose postgres and redis
  to local host machine thus you can connect local port via `psql` or
  `redis-cli`
- Wrap start up command in a standard `docker-entrypoint.sh`, and use
  `tail -f /dev/null` combined with manually `superset runserver -d` to
  make sure that code error didn't cause the container to fail.
- Use volumes to share code between host and container, thus you can use
  your favourite tools to modify code and your code will run in
  containerized environment
- Use volumes to persistent postgres and redis data, and also
  `node_modules` data.
  - If we don't cache `node_modules` in docker volume, then every time
    run docker build, the `node_modules` directory, will is about 500 MB
    large, will be sent to docker daemon, and make the build quite slow.
- Wrap initialization commands to a single script `docker-init.sh`

After this dockerize setup, any developers who want to contribute to
superset, just follow three easy steps:

```
git clone https://github.com/apache/incubator-superset/
cd incubator-superset
cp contrib/docker/{docker-build.sh,docker-compose.yml,docker-entrypoint.sh,docker-init.sh,Dockerfile} .
cp contrib/docker/superset_config.py superset/
bash -x docker-build.sh
docker-compose up -d
docker-compose exec superset bash
bash docker-init.sh
```
2018-06-09 21:26:41 -07:00

61 lines
1.7 KiB
Docker

FROM python:3.6
MAINTAINER Xiao Hanyu <hanyu.xiao@shopeemobile.com>
# Add a normal user
RUN useradd --user-group --create-home --shell /bin/bash work
# Configure environment
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
HOME=/home/work
RUN apt-get update -y
# Install some dependencies
# http://airbnb.io/superset/installation.html#os-dependencies
RUN apt-get update -y && apt-get install -y build-essential libssl-dev \
libffi-dev python3-dev libsasl2-dev libldap2-dev
RUN apt-get install -y vim less postgresql-client redis-tools
# Install nodejs for custom build
# https://github.com/apache/incubator-superset/blob/master/docs/installation.rst#making-your-own-build
# https://nodejs.org/en/download/package-manager/
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list; \
apt-get update; \
apt-get install -y yarn
RUN mkdir $HOME/incubator-superset
WORKDIR $HOME/incubator-superset
COPY ./ ./
RUN pip install --upgrade setuptools pip
RUN pip install -e . && pip install -r requirements-dev.txt
ENV PATH=/home/work/incubator-superset/superset/bin:$PATH \
PYTHONPATH=./superset/:$PYTHONPATH
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat
COPY ./superset ./superset
RUN chown -R work:work $HOME
USER work
RUN cd superset/assets && yarn
RUN cd superset/assets && npm run build
HEALTHCHECK CMD ["curl", "-f", "http://localhost:8088/health"]
ENTRYPOINT ["docker-entrypoint.sh"]
EXPOSE 8088