diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000000..5b282427c7f --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,16 @@ +# translate/pootle:base +# +# VERSION 0.0.1 + +FROM translate/pootle:root + +MAINTAINER Ryan Northey + +ENV POOTLE_LOG_DIR="$INSTALL_DIR/var/logs" + +COPY ./install-base /usr/local/bin +RUN ./usr/local/bin/install-base +COPY ./entrypoint.sh /usr/local/bin/entrypoint.sh + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] +EXPOSE 8000 diff --git a/docker/base/entrypoint.sh b/docker/base/entrypoint.sh new file mode 100755 index 00000000000..4a6c2c8fe13 --- /dev/null +++ b/docker/base/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Add local user +# Either use the LOCAL_USER_ID if passed in at runtime or +# fallback + +USER_ID=${LOCAL_USER_ID:$UID} + +echo "Starting with UID : $USER_ID" +usermod -o -u $USER_ID pootle +export HOME=/home/pootle +exec gosu pootle "$@" diff --git a/docker/base/install-base b/docker/base/install-base new file mode 100755 index 00000000000..65f964eb52d --- /dev/null +++ b/docker/base/install-base @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +apt-get update -qq +apt-get install \ + -y -qq \ + --no-install-recommends \ + gettext \ + gosu \ + make \ + python-dev +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile new file mode 100644 index 00000000000..5a30c8563fa --- /dev/null +++ b/docker/build/Dockerfile @@ -0,0 +1,17 @@ +# translate/pootle:base +# +# VERSION 0.0.1 + +FROM translate/pootle:root + +MAINTAINER Ryan Northey + +COPY ./install-build /usr/local/bin +RUN ./usr/local/bin/install-build + +USER pootle + +COPY ./install-virtualenv /usr/local/bin +RUN ./usr/local/bin/install-virtualenv + +USER root diff --git a/docker/build/install-build b/docker/build/install-build new file mode 100755 index 00000000000..b9b5b072663 --- /dev/null +++ b/docker/build/install-build @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +apt-get update -qq +apt-get install -y -qq \ + build-essential \ + coreutils \ + libjpeg-dev \ + libfreetype6-dev \ + liblcms2-dev \ + libtiff5-dev \ + libwebp-dev \ + libxml2-dev \ + libxslt-dev \ + python-dev \ + zlib1g-dev +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/docker/build/install-virtualenv b/docker/build/install-virtualenv new file mode 100755 index 00000000000..a005de217ca --- /dev/null +++ b/docker/build/install-virtualenv @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +INSTALL_DIR=$(readlink -f --canonicalize $(eval echo $INSTALL_DIR)) + +mkdir -p $INSTALL_DIR + +cd $INSTALL_DIR + +function get_requirement () { + curl -sO https://raw.githubusercontent.com/translate/pootle/master/requirements/$1.txt +} + +mkdir requirements +cd requirements +declare -a requirements=("_es_5" "base" "dev" "tests" "_docs" "_lint") +for i in "${requirements[@]}" +do + get_requirement "$i" +done +cd .. + +virtualenv . +. bin/activate \ + && pip install --no-cache-dir -qr requirements/dev.txt \ + && pip install --no-cache-dir -qr requirements/_es_5.txt \ + && pip install --no-cache-dir -q \ + codecov==2.0.15 \ + coverage==4.5.1 \ + coveralls==1.3.0 \ + && pyclean . + +cd $INSTALL_DIR +curl -s -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash +. ~/.nvm/nvm.sh + +nvm install node diff --git a/docker/dev-mariadb/Dockerfile b/docker/dev-mariadb/Dockerfile new file mode 100644 index 00000000000..6f381e3009d --- /dev/null +++ b/docker/dev-mariadb/Dockerfile @@ -0,0 +1,32 @@ +# translate/pootle:dev-mariadb +# +# VERSION 0.0.1 + +# Build stage +FROM translate/pootle:build + +COPY ./settings.conf /tmp/ +RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \ + && apt-get update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + libmariadbclient-dev-compat +USER pootle +RUN bash -c " \ + cd "$INSTALL_DIR" \ + && . bin/activate \ + && pip install -q \ + MySQL-python \ + && cp /tmp/settings.conf \ + /home/pootle/pootle_env/pootle.conf" + +# Mariadb dev +FROM translate/pootle:base + +ENV POOTLE_ENV=mariadb +RUN apt-get update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + libmariadbclient18 \ + mariadb-client +COPY --chown=pootle:pootle --from=0 /home/pootle/ /home/pootle diff --git a/docker/dev-mariadb/settings.conf b/docker/dev-mariadb/settings.conf new file mode 100644 index 00000000000..f686bf59ed8 --- /dev/null +++ b/docker/dev-mariadb/settings.conf @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- + +SECRET_KEY = 'SECRETKEY' +ALLOWED_HOSTS = [ + '127.0.0.1', + 'localhost', + #'${your_server}', +] + +DATABASES['default']['ENGINE'] = 'django.db.backends.mysql' +DATABASES['default']['NAME'] = 'pootle' +DATABASES['default']['USER'] = 'travis' +DATABASES['default']['TEST'] = dict( + COLLATION='utf8_general_ci', + NAME='', + CHARSET='utf8') +DATABASES['default']['OPTIONS'] = { + 'init_command': "SET sql_mode='STRICT_ALL_TABLES'"} diff --git a/docker/dev-mariadb/webapp.env b/docker/dev-mariadb/webapp.env new file mode 100644 index 00000000000..fd4a40d7aed --- /dev/null +++ b/docker/dev-mariadb/webapp.env @@ -0,0 +1,4 @@ +SECRET_KEY=insert_random_key +DJANGO_DEV=True +DJANGO_DEBUG=True +SITE_URL=http://localhost:8000 diff --git a/docker/dev-postgres/Dockerfile b/docker/dev-postgres/Dockerfile new file mode 100644 index 00000000000..f85a3431bff --- /dev/null +++ b/docker/dev-postgres/Dockerfile @@ -0,0 +1,32 @@ +# translate/pootle:dev-postgres +# +# VERSION 0.0.1 + +# Build stage +FROM translate/pootle:build + +COPY ./settings.conf /tmp/ +RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \ + && apt-get update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + libpq-dev +USER pootle +RUN bash -c " \ + cd "$INSTALL_DIR" \ + && . bin/activate \ + && pip install -q \ + psycopg2-binary \ + && cp /tmp/settings.conf \ + /home/pootle/pootle_env/pootle.conf" + +# Postgres dev +FROM translate/pootle:base + +ENV POOTLE_ENV=postgres +RUN mkdir -p /usr/share/man/man1 /usr/share/man/man7 \ + && apt-get update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + postgresql-client +COPY --chown=pootle:pootle --from=0 /home/pootle/ /home/pootle diff --git a/docker/dev-postgres/settings.conf b/docker/dev-postgres/settings.conf new file mode 100644 index 00000000000..0e2e58017a2 --- /dev/null +++ b/docker/dev-postgres/settings.conf @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +SECRET_KEY = 'SECRETKEY' +ALLOWED_HOSTS = [ + '127.0.0.1', + 'localhost', + #'${your_server}', +] + +DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql' +DATABASES['default']['NAME'] = 'pootle' +DATABASES['default']['USER'] = 'postgres' diff --git a/docker/dev-postgres/webapp.env b/docker/dev-postgres/webapp.env new file mode 100644 index 00000000000..fd4a40d7aed --- /dev/null +++ b/docker/dev-postgres/webapp.env @@ -0,0 +1,4 @@ +SECRET_KEY=insert_random_key +DJANGO_DEV=True +DJANGO_DEBUG=True +SITE_URL=http://localhost:8000 diff --git a/docker/dev-sqlite/Dockerfile b/docker/dev-sqlite/Dockerfile new file mode 100644 index 00000000000..5b28604e59b --- /dev/null +++ b/docker/dev-sqlite/Dockerfile @@ -0,0 +1,19 @@ +# translate/pootle:dev-sqlite +# +# VERSION 0.0.1 + +# Build stage +FROM translate/pootle:build + +COPY ./settings.conf /tmp/ +RUN cp /tmp/settings.conf /home/pootle/pootle_env/pootle.conf + +# Sqlite dev +FROM translate/pootle:base + +ENV POOTLE_ENV=sqlite +RUN apt-get update -qq \ + && apt-get install -qq -y \ + --no-install-recommends \ + sqlite3 +COPY --chown=pootle:pootle --from=0 /home/pootle/ /home/pootle diff --git a/docker/dev-sqlite/settings.conf b/docker/dev-sqlite/settings.conf new file mode 100644 index 00000000000..8e1f97d7160 --- /dev/null +++ b/docker/dev-sqlite/settings.conf @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +SECRET_KEY = 'SECRETKEY' +ALLOWED_HOSTS = [ + '127.0.0.1', + 'localhost', + #'${your_server}', +] diff --git a/docker/dev-sqlite/webapp.env b/docker/dev-sqlite/webapp.env new file mode 100644 index 00000000000..fd4a40d7aed --- /dev/null +++ b/docker/dev-sqlite/webapp.env @@ -0,0 +1,4 @@ +SECRET_KEY=insert_random_key +DJANGO_DEV=True +DJANGO_DEBUG=True +SITE_URL=http://localhost:8000 diff --git a/docker/root/Dockerfile b/docker/root/Dockerfile new file mode 100644 index 00000000000..191814cb801 --- /dev/null +++ b/docker/root/Dockerfile @@ -0,0 +1,16 @@ +# translate/pootle:root +# +# VERSION 0.0.1 + +FROM debian:stretch-slim + +MAINTAINER Ryan Northey + +ENV DEBIAN_FRONTEND=noninteractive \ + INSTALL_DIR=~/pootle_env \ + POOTLE_PKG='-e git://github.com/translate/pootle#egg=pootle' \ + POOTLE_LOG_DIR="$INSTALL_DIR/var/logs" + +COPY ./install-root /usr/local/bin +COPY ./no-apt-cache /etc/apt/apt.conf.d/02nocache +RUN ./usr/local/bin/install-root diff --git a/docker/root/install-root b/docker/root/install-root new file mode 100755 index 00000000000..87906fb9dde --- /dev/null +++ b/docker/root/install-root @@ -0,0 +1,31 @@ +#!/bin/bash + +# Installs/configures the packages used in all images +# and creates the pootle user + +set -e + +apt-get update -qq +apt-get install \ + -y \ + -qq \ + --no-install-recommends \ + curl \ + git \ + locales \ + python-pip \ + sudo +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +rm -rf /var/cache/apt/archives +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen +update-locale LANG=en_US.UTF-8 +pip install --no-cache-dir -q virtualenv +groupadd -r pootle +useradd \ + -m \ + -d /home/pootle \ + -k /etc/skel \ + -s /bin/bash \ + -g pootle \ + pootle diff --git a/docker/root/no-apt-cache b/docker/root/no-apt-cache new file mode 100644 index 00000000000..6add3a98c88 --- /dev/null +++ b/docker/root/no-apt-cache @@ -0,0 +1,2 @@ +Dir::Cache ""; +Dir::Cache::archives "";