2020-02-08 20:06:46 +01:00
|
|
|
FROM python:3.8-slim
|
2020-02-05 18:51:41 +01:00
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
RUN mkdir /code
|
|
|
|
WORKDIR /code
|
2020-02-08 20:06:46 +01:00
|
|
|
|
2020-02-09 21:21:06 +01:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends gnupg \
|
2020-02-08 20:59:20 +01:00
|
|
|
&& apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 \
|
|
|
|
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
2020-02-09 21:21:06 +01:00
|
|
|
&& apt-get update && apt-get install -y --no-install-recommends \
|
2020-04-07 12:13:39 +02:00
|
|
|
postgresql redis-server \
|
2020-02-09 21:21:06 +01:00
|
|
|
&& apt-get purge -y gnupg \
|
2020-02-08 20:06:46 +01:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# START POSTGRES
|
|
|
|
# Run the next command as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
|
|
|
|
USER postgres
|
|
|
|
# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
|
|
|
|
# then create a database `docker` owned by the ``docker`` role.
|
|
|
|
RUN /etc/init.d/postgresql start &&\
|
|
|
|
psql --command "CREATE USER posthog WITH SUPERUSER PASSWORD 'posthog';" &&\
|
|
|
|
createdb posthog
|
|
|
|
# END POSGRES
|
|
|
|
|
|
|
|
USER root
|
|
|
|
|
2020-04-07 12:13:39 +02:00
|
|
|
RUN /etc/init.d/redis-server start
|
|
|
|
|
2020-02-05 18:51:41 +01:00
|
|
|
COPY requirements.txt /code/
|
2020-02-09 21:21:06 +01:00
|
|
|
# install dependencies but ignore any we don't need for dev environment
|
2020-02-14 08:00:59 +01:00
|
|
|
RUN pip install $(grep -ivE "drf-yasg|psycopg2|ipdb|mypy|ipython|ipdb|pip|djangorestframework-stubs|django-stubs|ipython-genutils|mypy-extensions|Pygments|typed-ast|jedi" requirements.txt) --no-cache-dir --compile\
|
2020-02-12 04:54:58 +01:00
|
|
|
&& pip install psycopg2-binary --no-cache-dir --compile\
|
2020-02-10 00:20:11 +01:00
|
|
|
&& pip uninstall ipython-genutils pip -y \
|
|
|
|
&& rm -rf /usr/local/lib/python3.8/site-packages/numpy/core/tests \
|
|
|
|
&& rm -rf /usr/local/lib/python3.8/site-packages/pandas/tests
|
|
|
|
|
2020-03-14 16:38:13 +01:00
|
|
|
COPY package.json /code/
|
|
|
|
COPY yarn.lock /code/
|
|
|
|
COPY webpack.config.js /code/
|
|
|
|
COPY postcss.config.js /code/
|
|
|
|
COPY .babelrc /code/
|
2020-02-08 20:06:46 +01:00
|
|
|
COPY frontend/ /code/frontend
|
2020-03-14 16:38:13 +01:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends curl \
|
2020-02-09 21:21:06 +01:00
|
|
|
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
|
|
|
|
&& apt-get install nodejs -y --no-install-recommends \
|
2020-03-14 16:51:49 +01:00
|
|
|
&& npm install -g yarn@1 \
|
|
|
|
&& yarn --frozen-lockfile \
|
|
|
|
&& yarn build \
|
2020-04-07 11:41:46 +02:00
|
|
|
&& yarn cache clean \
|
2020-03-14 16:51:49 +01:00
|
|
|
&& npm uninstall -g yarn \
|
2020-02-09 21:21:06 +01:00
|
|
|
&& apt-get purge -y nodejs curl \
|
2020-02-08 20:06:46 +01:00
|
|
|
&& rm -rf node_modules \
|
|
|
|
&& rm -rf /var/lib/apt/lists/* \
|
2020-02-10 00:20:11 +01:00
|
|
|
&& rm -rf frontend/dist/*.map
|
2020-02-08 20:06:46 +01:00
|
|
|
|
|
|
|
COPY . /code/
|
2020-04-02 00:46:29 +02:00
|
|
|
|
2020-04-07 12:13:39 +02:00
|
|
|
RUN DATABASE_URL='postgres:///' REDIS_URL='redis:///' python manage.py collectstatic --noinput
|
2020-04-02 00:46:29 +02:00
|
|
|
|
2020-02-09 21:21:06 +01:00
|
|
|
RUN /etc/init.d/postgresql start\
|
2020-04-07 12:13:39 +02:00
|
|
|
&& DATABASE_URL=postgres://posthog:posthog@localhost:5432/posthog REDIS_URL='redis:///' python manage.py migrate\
|
2020-02-09 21:21:06 +01:00
|
|
|
&& /etc/init.d/postgresql stop
|
|
|
|
|
2020-02-08 20:06:46 +01:00
|
|
|
VOLUME /var/lib/postgresql
|
2020-02-09 21:21:06 +01:00
|
|
|
EXPOSE 8000
|
2020-03-14 16:38:13 +01:00
|
|
|
ENTRYPOINT ["./bin/docker-preview"]
|