adapt docker env for new version of debian

This commit is contained in:
Cayo Puigdefabregas 2021-01-28 12:20:45 +01:00
parent e2ef8823f8
commit 44ebd42942
5 changed files with 268 additions and 251 deletions

View File

@ -21,7 +21,7 @@ If you are planing to do some development you may want to consider doing it unde
3. Deploy django-orchestra development environment, inside the container
```bash
bash <( curl -L http://git.io/orchestra-deploy ) --dev
bash <( curl -L https://raw.githubusercontent.com/ribaguifi/django-orchestra/docker/scripts/containers/orchestra-deploy ) --dev
```
3. Nginx should be serving on port 80, but Django's development server can be used as well:
@ -34,5 +34,5 @@ If you are planing to do some development you may want to consider doing it unde
5. To upgrade to current master just re-run the deploy script
```bash
git pull origin master
bash <( curl -L http://git.io/orchestra-deploy ) --dev
bash <( curl -L https://raw.githubusercontent.com/ribaguifi/django-orchestra/docker/scripts/containers/orchestra-deploy ) --dev
```

132
install_manually.md Normal file
View File

@ -0,0 +1,132 @@
# System requirements:
The most important requirement is use python3.6
we need install this packages:
```
bind9utils
ca-certificates
gettext
libcrack2-dev
libxml2-dev
libxslt1-dev
python3
python3-pip
python3-dev
ssh-client
wget
xvfb
zlib1g-dev
git
iceweasel
dnsutils
```
We need install too a *wkhtmltopdf* package
You can use one of your OS or get it from original.
This it is in https://wkhtmltopdf.org/downloads.html
# pip installations
We need install this packages:
```
Django==1.10.5
django-fluent-dashboard==0.6.1
django-admin-tools==0.8.0
django-extensions==1.7.4
django-celery==3.1.17
celery==3.1.23
kombu==3.0.35
billiard==3.3.0.23
Markdown==2.4
djangorestframework==3.4.7
ecdsa==0.11
Pygments==1.6
django-filter==0.15.2
jsonfield==0.9.22
python-dateutil==2.2
https://github.com/glic3rinu/passlib/archive/master.zip
django-iban==0.3.0
requests
phonenumbers
django-countries
django-localflavor
amqp
anyjson
pytz
cracklib
lxml==3.3.5
selenium
xvfbwrapper
freezegun
coverage
flake8
django-debug-toolbar==1.3.0
django-nose==1.4.4
sqlparse
pyinotify
PyMySQL
```
If you want to use Orchestra you need to install from pip like this:
```
pip3 install http://git.io/django-orchestra-dev
```
But if you want develop orquestra you need to do this:
```
git clone https://github.com/ribaguifi/django-orchestra
pip install -e django-orchestra
```
# Database
For default use sqlite3 if you want to use postgresql you need install this packages:
```
psycopg2 postgresql
```
You can use it for debian or ubuntu:
```
sudo apt-get install python3-psycopg2 postgresql-contrib
```
Remember create a database for your project and give permitions for the correct user like this:
```
psql -U postgres
psql (12.4)
Digite «help» para obtener ayuda.
postgres=# CREATE database orchesta;
postgres=# CREATE USER orchesta WITH PASSWORD 'orquesta';
postgres=# GRANT ALL PRIVILEGES ON DATABASE orchesta TO orchesta;
```
# Create new project
You can use orchestra-admin for create your new project
```
orchestra-admin startproject <project_name> # e.g. panel
cd <project_name>
```
Next we need change the settings.py for configure the correct database
In settings.py we need change the DATABASE section like this:
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'orchestra'
'USER': 'orchestra',
'PASSWORD': 'orchestra',
'HOST': 'localhost',
'PORT': '5432',
'CONN_MAX_AGE': 60*10
}
}
```
For end you need to do the migrations:
```
python3 manage.py migrate
```

View File

@ -174,7 +174,7 @@ function install_requirements () {
minor=$(echo -e "$wkhtmltox_version\n0.12.2.1" | sort -V | head -n 1)
if [[ ! $wkhtmltox_version ]] || [[ $wkhtmltox_version != 0.12.2.1 && $minor == ${wkhtmltox_version} ]]; then
wkhtmltox=$(mktemp)
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox}
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb -O ${wkhtmltox}
dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; }
fi
}

View File

@ -1,4 +1,134 @@
FROM debian:9-slim
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
FROM buildpack-deps:buster
# ensure local python is preferred over distribution python
ENV PATH /usr/local/bin:$PATH
# http://bugs.python.org/issue19846
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
ENV LANG C.UTF-8
# extra dependencies (over what buildpack-deps already includes)
RUN apt-get update && apt-get install -y --no-install-recommends \
libbluetooth-dev \
tk-dev \
&& rm -rf /var/lib/apt/lists/*
ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
ENV PYTHON_VERSION 3.6.12
RUN set -ex \
\
&& wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
&& wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
&& gpg --batch --verify python.tar.xz.asc python.tar.xz \
&& { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \
&& rm -rf "$GNUPGHOME" python.tar.xz.asc \
&& mkdir -p /usr/src/python \
&& tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
&& rm python.tar.xz \
\
&& cd /usr/src/python \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure \
--build="$gnuArch" \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking=fatal \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--without-ensurepip \
&& make -j "$(nproc)" \
# setting PROFILE_TASK makes "--enable-optimizations" reasonable: https://bugs.python.org/issue36044 / https://github.com/docker-library/python/issues/160#issuecomment-509426916
PROFILE_TASK='-m test.regrtest --pgo \
test_array \
test_base64 \
test_binascii \
test_binhex \
test_binop \
test_bytes \
test_c_locale_coercion \
test_class \
test_cmath \
test_codecs \
test_compile \
test_complex \
test_csv \
test_decimal \
test_dict \
test_float \
test_fstring \
test_hashlib \
test_io \
test_iter \
test_json \
test_long \
test_math \
test_memoryview \
test_pickle \
test_re \
test_set \
test_slice \
test_struct \
test_threading \
test_time \
test_traceback \
test_unicode \
' \
&& make install \
&& rm -rf /usr/src/python \
\
&& find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \
-o \( -type f -a -name 'wininst-*.exe' \) \
\) -exec rm -rf '{}' + \
\
&& ldconfig \
\
&& python3 --version
# make some useful symlinks that are expected to exist
RUN cd /usr/local/bin \
&& ln -s idle3 idle \
&& ln -s pydoc3 pydoc \
&& ln -s python3 python \
&& ln -s python3-config python-config
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 21.0
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/8cc88aca7d9775fce279e8b84ef163cf1d3e8a2e/get-pip.py
ENV PYTHON_GET_PIP_SHA256 ffb67da2e976f48dd29714fc64812d1ac419eb7d48079737166dd95640d1debd
RUN set -ex; \
\
wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \
echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum --check --strict -; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
"pip==$PYTHON_PIP_VERSION" \
; \
pip --version; \
\
find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \
\( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \
\) -exec rm -rf '{}' +; \
rm -f get-pip.py
RUN apt-get -y update && apt-get install -y curl sudo
@ -10,3 +140,5 @@ RUN useradd orchestra --shell /bin/bash && \
{ echo "orchestra:orchestra" | chpasswd; } && \
mkhomedir_helper orchestra && \
adduser orchestra sudo
CMD ["python3"]

View File

@ -1,247 +0,0 @@
#!/bin/bash
set -u
set -e
bold=$(tput -T ${TERM:-xterm} bold)
normal=$(tput -T ${TERM:-xterm} sgr0)
PYTHON_BIN='python3'
function help () {
if [[ $# -gt 1 ]]; then
CMD="print_${2}_help"
$CMD
else
print_help
fi
}
function print_help () {
cat <<- EOF
${bold}NAME${normal}
${bold}orchestra-admin${normal} - Orchetsra administration script
${bold}OPTIONS${normal}
${bold}install_requirements${normal}
Installs Orchestra requirements using apt-get and pip
${bold}startproject${normal}
Creates a new Django-orchestra instance
${bold}help${normal}
Displays this help text or related help page as argument
for example:
${bold}orchestra-admin help startproject${normal}
EOF
}
show () {
echo " ${bold}\$ ${@}${normal}"
}
export -f show
run () {
show "${@}"
"${@}"
}
export -f run
check_root () {
[ $(whoami) != 'root' ] && { echo -e "\nErr. This should be run as root\n" >&2; exit 1; }
}
export -f check_root
get_orchestra_dir () {
if ! $(echo "import orchestra" | $PYTHON_BIN 2> /dev/null); then
echo -e "\norchestra not installed.\n" >&2
exit 1
fi
PATH=$(echo "import orchestra, os; print(os.path.dirname(os.path.realpath(orchestra.__file__)))" | $PYTHON_BIN)
echo $PATH
}
export -f get_orchestra_dir
function print_install_requirements_help () {
cat <<- EOF
${bold}NAME${normal}
${bold}orchetsra-admin install_requirements${normal} - Installs all Orchestra requirements using apt-get and pip
${bold}OPTIONS${normal}
${bold}-t, --testing${normal}
Install Orchestra normal requirements plus those needed for running functional tests
${bold}-h, --help${normal}
Displays this help text
EOF
}
function install_requirements () {
opts=$(getopt -o h,t -l help,testing -- "$@") || exit 1
set -- $opts
testing=false
while [ $# -gt 0 ]; do
case $1 in
-h|--help) print_deploy_help; exit 0 ;;
-t|--testing) testing=true; shift ;;
(--) shift; break;;
(-*) echo "$0: Err. - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
unset OPTIND
unset opt
check_root || true
ORCHESTRA_PATH=$(get_orchestra_dir) || true
# Make sure locales are in place before installing postgres
if [[ $({ perl --help > /dev/null; } 2>&1|grep 'locale failed') ]]; then
run sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /etc/locale.gen
run locale-gen
update-locale LANG=en_US.UTF-8
fi
# lxml: libxml2-dev, libxslt1-dev, zlib1g-dev
APT="bind9utils \
ca-certificates \
gettext \
libcrack2-dev \
libxml2-dev \
libxslt1-dev \
python3 \
python3-pip \
python3-dev \
ssh-client \
wget \
xvfb \
zlib1g-dev"
if $testing; then
APT="${APT} \
git \
iceweasel \
dnsutils"
fi
run apt-get update
run apt-get install -y $APT
# Install ca certificates before executing pip install
if [[ ! -e /usr/local/share/ca-certificates/cacert.org ]]; then
mkdir -p /usr/local/share/ca-certificates/cacert.org
wget -P /usr/local/share/ca-certificates/cacert.org \
http://www.cacert.org/certs/root.crt \
http://www.cacert.org/certs/class3.crt
update-ca-certificates
fi
# cracklib and lxml are excluded on the requirements.txt because they need unconvinient system dependencies
PIP="$(wget http://git.io/orchestra-requirements.txt -O - | tr '\n' ' ') \
cracklib \
lxml==3.3.5"
if $testing; then
PIP="${PIP} \
selenium \
xvfbwrapper \
freezegun \
coverage \
flake8 \
django-debug-toolbar==1.3.0 \
django-nose==1.4.4 \
sqlparse \
pyinotify \
PyMySQL"
fi
run pip3 install $PIP
# Install a more recent version of wkhtmltopdf (0.12.2) (PDF page number support)
wkhtmltox_version=$(dpkg --list | grep wkhtmltox | awk {'print $3'})
minor=$(echo -e "$wkhtmltox_version\n0.12.2.1" | sort -V | head -n 1)
if [[ ! $wkhtmltox_version ]] || [[ $wkhtmltox_version != 0.12.2.1 && $minor == ${wkhtmltox_version} ]]; then
wkhtmltox=$(mktemp)
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb -O ${wkhtmltox}
#wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-jessie-amd64.deb -O ${wkhtmltox}
dpkg -i ${wkhtmltox} || { echo "Installing missing dependencies for wkhtmltox..." && apt-get -f -y install; }
fi
}
export -f install_requirements
print_startproject_help () {
cat <<- EOF
${bold}NAME${normal}
${bold}orchestra-admin startproject${normal} - Create a new Django-Orchestra instance
${bold}SYNOPSIS${normal}
Options: [ -h ]
${bold}OPTIONS${normal}
${bold}-h, --help${normal}
This help message
${bold}EXAMPLES${normal}
orchestra-admin startproject controlpanel
EOF
}
function startproject () {
local PROJECT_NAME="$2"; shift
opts=$(getopt -o h -l help -- "$@") || exit 1
set -- $opts
set -- $opts
while [ $# -gt 0 ]; do
case $1 in
-h|--help) print_startproject_help; exit 0 ;;
(--) shift; break;;
(-*) echo "$0: Err. - unrecognized option $1" 1>&2; exit 1;;
(*) break;;
esac
shift
done
unset OPTIND
unset opt
[ $(whoami) == 'root' ] && { echo -e "\nYou don't want to run this as root\n" >&2; exit 1; }
ORCHESTRA_PATH=$(get_orchestra_dir) || { echo "Error getting orchestra dir"; exit 1; }
if [[ ! -e $PROJECT_NAME/manage.py ]]; then
run django-admin.py startproject $PROJECT_NAME --template="${ORCHESTRA_PATH}/conf/project_template"
# This is a workaround for this issue https://github.com/pypa/pip/issues/317
run chmod +x $PROJECT_NAME/manage.py
# End of workaround ###
else
echo "Not cloning: $PROJECT_NAME already exists."
fi
# Install bash autocompletition for django commands
if [[ ! $(grep 'source $HOME/.django_bash_completion.sh' ~/.bashrc &> /dev/null) ]]; then
# run wget https://raw.github.com/django/django/master/extras/django_bash_completion \
# --no-check-certificate -O ~/.django_bash_completion.sh
cp ${ORCHESTRA_PATH}/bin/django_bash_completion.sh ~/.django_bash_completion.sh
echo 'source $HOME/.django_bash_completion.sh' >> ~/.bashrc
fi
}
export -f startproject
[ $# -lt 1 ] && { print_help; exit 1; }
$1 "${@}"