forked from PostHog/posthog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
preview.Dockerfile
56 lines (48 loc) · 2.26 KB
/
preview.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
FROM python:3.8-slim
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN apt-get update && apt-get install -y --no-install-recommends gnupg \
&& 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 \
&& apt-get update && apt-get install -y --no-install-recommends \
postgresql \
&& apt-get purge -y gnupg \
&& 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
COPY requirements.txt /code/
# install dependencies but ignore any we don't need for dev environment
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\
&& pip install psycopg2-binary --no-cache-dir --compile\
&& 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
COPY frontend/ /code/frontend
RUN cd frontend \
&& apt-get update && apt-get install -y --no-install-recommends curl \
&& curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install nodejs -y --no-install-recommends \
&& npm install \
&& npm cache clean --force \
&& npm run build \
&& apt-get purge -y nodejs curl \
&& rm -rf node_modules \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf .cache \
&& rm -rf frontend/dist/*.map
COPY . /code/
RUN /etc/init.d/postgresql start\
&& DATABASE_URL=postgres://posthog:posthog@localhost:5432/posthog python manage.py migrate\
&& /etc/init.d/postgresql stop
VOLUME /var/lib/postgresql
EXPOSE 8000
ENTRYPOINT ["./bin/docker-preview"]