<commit_before>FROM ubuntu:14.04
ENV PYTHONUNBUFFERED 1
EXPOSE 8000

# Install basics
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y build-essential postgresql git python-dev
RUN apt-get install -y python-virtualenv python3-pip graphviz-dev libpq-dev # faster builds

# Install maildump
EXPOSE 1080
RUN pip install maildump

# Install nodejs
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash
RUN apt-get update && apt-get install -y nodejs

# Create database
USER postgres
RUN service postgresql start && \
    createuser asylum && \
    createdb -E utf-8 -T template0 -O asylum asylum && \
    psql -U postgres -d postgres -c "alter user asylum with password '<PASSWORD>'; alter user asylum with createdb;"

# Create a newuser
USER root
RUN adduser --disabled-password --gecos '' asylum && \
    adduser asylum sudo && \
    echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create volume
RUN mkdir /opt/asylum/ && chown asylum:asylum /opt/asylum/
# VOLUME /opt/asylum/ # Your local uid != 1000? Tough. Create an issue and add an idea how to fix it.
WORKDIR /opt/asylum/

# Install system packages
COPY project/requirements.apt /opt/asylum/
RUN awk '/^\s*[^#]/' requirements.apt | xargs -r -- sudo apt-get install --no-install-recommends -y

# Configure locales
USER root
RUN locale-gen en_US.UTF-8
ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en

# Install python requirements
RUN virtualenv -p `which python3.4` ../asylum-venv
COPY project/requirements /opt/asylum/requirements/
RUN . ../asylum-venv/bin/activate && pip install -r requirements/local.txt

# Configure application
USER root
RUN echo "DATABASE_URL=postgres://asylum:asylum@localhost/asylum" > .env
COPY project /opt/asylum/
RUN chown -R asylum:asylum /opt/asylum/

# Build localisations
USER asylum
RUN . ../asylum-venv/bin/activate && \
    for app in locale */locale; do (cd $(dirname $app) && ../manage.py compilemessages ); done

# Test npm (this will happen again at entrypoint)
USER asylum
RUN npm run build

# Run migrate and create admin user
USER asylum
RUN sudo -u postgres service postgresql start; \
    . ../asylum-venv/bin/activate && \
    export PGPASSWORD=<PASSWORD>lum; while true; do psql -q asylum -c 'SELECT 1;' 1>/dev/null 2>&1 ; if [ "$?" -ne "0" ]; then echo "Waiting for psql"; sleep 1; else break; fi; done && \
    ./manage.py migrate && \
    echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '<EMAIL>', 'admin') ; from rest_framework.authtoken.models import Token ; Token.objects.create(user=User.objects.get(username='admin'), key='deadbeefdeadbeefdeadbeefdeadbeefdeadbeef')" | ./manage.py shell
<commit_msg>workaround dependency chain error in some of our deps<commit_after>FROM ubuntu:14.04
ENV PYTHONUNBUFFERED 1
EXPOSE 8000

# Install basics
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y build-essential postgresql git python-dev
RUN apt-get install -y python-virtualenv python3-pip graphviz-dev libpq-dev # faster builds

# Install maildump
EXPOSE 1080
RUN pip install maildump

# Install nodejs
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash
RUN apt-get update && apt-get install -y nodejs

# Create database
USER postgres
RUN service postgresql start && \
    createuser asylum && \
    createdb -E utf-8 -T template0 -O asylum asylum && \
    psql -U postgres -d postgres -c "alter user asylum with password '<PASSWORD>'; alter user asylum with createdb;"

# Create a newuser
USER root
RUN adduser --disabled-password --gecos '' asylum && \
    adduser asylum sudo && \
    echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create volume
RUN mkdir /opt/asylum/ && chown asylum:asylum /opt/asylum/
# VOLUME /opt/asylum/ # Your local uid != 1000? Tough. Create an issue and add an idea how to fix it.
WORKDIR /opt/asylum/

# Install system packages
COPY project/requirements.apt /opt/asylum/
RUN awk '/^\s*[^#]/' requirements.apt | xargs -r -- sudo apt-get install --no-install-recommends -y

# Configure locales
USER root
RUN locale-gen en_US.UTF-8
ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en

# Install python requirements
RUN virtualenv -p `which python3.4` ../asylum-venv
COPY project/requirements /opt/asylum/requirements/
RUN . ../asylum-venv/bin/activate && pip install packaging appdirs && pip install -r requirements/local.txt

# Configure application
USER root
RUN echo "DATABASE_URL=postgres://asylum:asylum@localhost/asylum" > .env
COPY project /opt/asylum/
RUN chown -R asylum:asylum /opt/asylum/

# Build localisations
USER asylum
RUN . ../asylum-venv/bin/activate && \
    for app in locale */locale; do (cd $(dirname $app) && ../manage.py compilemessages ); done

# Test npm (this will happen again at entrypoint)
USER asylum
RUN npm run build

# Run migrate and create admin user
USER asylum
RUN sudo -u postgres service postgresql start; \
    . ../asylum-venv/bin/activate && \
    export PGPASSWORD=<PASSWORD>; while true; do psql -q asylum -c 'SELECT 1;' 1>/dev/null 2>&1 ; if [ "$?" -ne "0" ]; then echo "Waiting for psql"; sleep 1; else break; fi; done && \
    ./manage.py migrate && \
    echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '<EMAIL>', 'admin') ; from rest_framework.authtoken.models import Token ; Token.objects.create(user=User.objects.get(username='admin'), key='deadbeefdeadbeefdeadbeefdeadbeefdeadbeef')" | ./manage.py shell

{'fraction_non_alphanumeric': 0.11857707509881422, 'fraction_numerical': 0.011498383039885016, 'mean_word_length': 3.725806451612903, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5669607', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1790, 'n_words': 622}