Skip to content

Instantly share code, notes, and snippets.

@rscircus
Forked from alonisser/Dockerfile
Created March 10, 2020 09:23
Show Gist options
  • Save rscircus/429f8d278a6615575337cb15fa4da7c0 to your computer and use it in GitHub Desktop.
Save rscircus/429f8d278a6615575337cb15fa4da7c0 to your computer and use it in GitHub Desktop.

Revisions

  1. @alonisser alonisser revised this gist Jan 4, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,7 @@ RUN apk add --no-cache postgresql-libs && \
    apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev g++
    RUN mkdir -pv /prodigy /prodigy/src
    WORKDIR /prodigy
    # the prodigy wheel file is something you get when you buy prodigy, it's not a free package
    COPY ./*.whl /prodigy
    COPY requirements.txt /prodigy
    RUN pip install -r requirements.txt --no-cache-dir \
    @@ -39,6 +40,7 @@ COPY src/* /prodigy/src/
    # Comment the two next lines if you don't override the index.html file
    COPY static/index.html index.html
    RUN PRODIGY_FILES=`python -c "import prodigy; print(prodigy.__file__.replace(\"__init__.py\",''))"`; cp index.html $PRODIGY_FILES/static/
    # The actual entry point compiling the template
    CMD ["dockerize", "-template", "/prodigy/prodigy.json.tpl:/prodigy/prodigy.json", "./launch.sh"]

    EXPOSE 8080
  2. @alonisser alonisser renamed this gist Jan 4, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @alonisser alonisser created this gist Jan 4, 2019.
    45 changes: 45 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    FROM python:3.6-alpine
    # Opted for alpine to get a lean docker image as possible
    RUN apk add --no-cache openssl

    ENV DOCKERIZE_VERSION v0.6.1
    RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

    # Python deps for alpine
    RUN apk add --no-cache postgresql-libs && \
    apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev g++
    RUN mkdir -pv /prodigy /prodigy/src
    WORKDIR /prodigy
    COPY ./*.whl /prodigy
    COPY requirements.txt /prodigy
    RUN pip install -r requirements.txt --no-cache-dir \
    && find /usr/local \
    \( -type d -a -name test -o -name tests \) \
    -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
    -exec rm -rf '{}' + \
    && runDeps="$( \
    scanelf --needed --nobanner --recursive /usr/local \
    | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
    | sort -u \
    | xargs -r apk info --installed \
    | sort -u \
    )" \
    && apk add --virtual .rundeps $runDeps \
    && apk del .build-deps

    ENV PRODIGY_HOME /prodigy
    # the template that dockerize would use to create the actual prodigy.json config based on environment variables
    COPY ./prodigy.json.tpl /prodigy/prodigy.json.tpl
    #Preparing an instructions file
    COPY ./instructions.txt /prodigy/instructions.txt
    COPY *.sh /prodigy/
    COPY src/* /prodigy/src/
    # Comment the two next lines if you don't override the index.html file
    COPY static/index.html index.html
    RUN PRODIGY_FILES=`python -c "import prodigy; print(prodigy.__file__.replace(\"__init__.py\",''))"`; cp index.html $PRODIGY_FILES/static/
    CMD ["dockerize", "-template", "/prodigy/prodigy.json.tpl:/prodigy/prodigy.json", "./launch.sh"]

    EXPOSE 8080

    20 changes: 20 additions & 0 deletions prodigy,json.tpl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    {
    "batch_size": 5,
    "host":"0.0.0.0",
    "instructions":"/prodigy/instructions.txt",
    "hide_meta": true,
    "choice_auto_accept": true,
    "db": "postgresql",
    "db_settings": {
    "postgresql": {
    "host":"{{ .Env.DB_HOST }}",
    "dbname": "{{ .Env.DATABASE_NAME }}",
    "port": 5432,
    "user":"{{ .Env.DB_USERNAME }}",
    "password":"{{ .Env.DB_PASSWORD }}"
    }
    }
    }