diff --git a/Dockerfile b/Dockerfile index 592a4002..d3adde24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,19 +11,21 @@ WORKDIR /home/ubuntu FROM ubuntu-base AS ubuntu-provisioned USER root +# Build-time variables. +ARG HTTPS_PROXY +ARG HTTP_PROXY +ARG PROVISION_AHK=0 +ARG PROVISION_CHARLES=0 +ARG PROVISION_MONO=0 +ARG PROVISION_SSH=0 +ARG PROVISION_SUDO=1 +ARG PROVISION_VNC=1 + # Provision container image. COPY ansible /opt/ansible COPY scripts /opt/scripts ENV PATH $PATH:/opt/scripts:/opt/scripts/py -#ENV PROVISION_HASH KwFCBBn659lGNLNiIGd5131XnknI -#RUN provision.sh - -RUN apt update \ - && apt -qqq install ansible git \ - && ansible-galaxy install git+https://github.com/EA31337/ansible-role-mt-runner.git,dev \ - && ansible-playbook -i "localhost," -c local /opt/ansible/mt-install.yml -v \ - && rm -fr ~/.ansible /tmp/* \ - && find /var/lib/apt/lists -type f -delete +RUN provision.sh # Uses ubuntu as default user. USER ubuntu @@ -46,7 +48,7 @@ VOLUME $BT_DEST FROM ea-tester-base AS ea-tester-with-mt4 # Install platform. -RUN ansible-playbook -i "localhost," -c local -e metatrader_version=4 /opt/ansible/mt-install.yml -v \ +#RUN ansible-playbook -i "localhost," -c local -e metatrader_version=4 /opt/ansible/mt-install.yml -v \ #ARG MT_VER=4 #RUN eval.sh install_mt $MT_VER && run_backtest.sh -s PrintPaths -v @@ -62,7 +64,7 @@ FROM ea-tester-base AS ea-tester-with-mt5 # Install platform. ARG MT_VER=5 ENV MT_VER $MT_VER -RUN ansible-playbook -i "localhost," -c local -e metatrader_version=5 /opt/ansible/mt-install.yml -v \ +#RUN ansible-playbook -i "localhost," -c local -e metatrader_version=5 /opt/ansible/mt-install.yml -v \ #RUN eval.sh install_mt $MT_VER #RUN run_backtest.sh -s PrintPaths -v diff --git a/scripts/provision.sh b/scripts/provision.sh index 456d3748..5c225ba5 100755 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -76,6 +76,7 @@ case "$(uname -s)" in echo "Configuring APT..." >&2 apt-config dump | grep -we Recommends -e Suggests | sed s/1/0/ | tee /etc/apt/apt.conf.d/99norecommend apt-config dump | grep -we Recommends -e Suggests + if command -v dpkg-reconfigure > /dev/null; then # Perform an unattended installation of a Debian packages. @@ -103,80 +104,15 @@ case "$(uname -s)" in ) # Install curl and wget if not present. + command -v ansible &> /dev/null || apt-get install -qq ansible command -v curl &> /dev/null || apt-get install -qq curl command -v wget &> /dev/null || apt-get install -qq wget - # CA certificates to allow SSL-based applications to check for the authenticity of SSL connections. - echo "Installing CA certificates and GnuPG..." >&2 - apt-get install -qq ca-certificates gnupg - # Add PPA/Wine repository. - echo "Adding PPA/Wine repository..." >&2 - # Adds GPG release key. - apt-key add < <(curl -S https://dl.winehq.org/wine-builds/winehq.key) - # APT dependencies (for the add-apt-repository). - command -v add-apt-repository || apt-get install -qq software-properties-common - # Adds APT Wine repository. - add-apt-repository -y "deb http://dl.winehq.org/wine-builds/ubuntu/ ${DISTRIB_CODENAME:-bionic} main" - - # Install Charles proxy. - if (("$PROVISION_CHARLES")); then - # Install Charles Root Certificate (if available). - curl -L chls.pro/ssl > /usr/local/share/ca-certificates/charles.crt && update-ca-certificates - # Adds GPG release key. - apt-key add < <(curl -S https://www.charlesproxy.com/packages/apt/PublicKey) - # Adds APT repository. - add-apt-repository -y "deb https://www.charlesproxy.com/packages/apt/ charles-proxy main" - # Install HTTPS transport driver. - apt-get install -qq apt-transport-https - fi - - # Update APT index. - ! (("${NO_APT_UPDATE:-0}")) && ( - echo "Updating APT packages..." >&2 - apt-get -qq update - ) + # Install MT runner. + ansible-galaxy install git+https://github.com/EA31337/ansible-role-mt-runner.git,dev - # Install necessary packages - echo "Installing APT packages..." >&2 - apt-get install -qq build-essential # Install C, C++ compilers and development (make). - apt-get install -qq dbus # Required for Debian AMI on EC2. - apt-get install -qq fontconfig # Required for fc-match command. - apt-get install -qq language-pack-en # Language pack to prevent an invalid locale. - apt-get install -qq crudini pev # Install CLI tools. - - # Install wine and dependencies. - # @see: https://wiki.winehq.org/Ubuntu - apt-get install -qq winehq-devel # Install Wine. - apt-get install -qq wine-gecko winbind || true # Install Wine recommended libraries. - apt-get install -qq xvfb xdotool x11-utils xterm # Virtual frame buffer and X11 utils. - - # Install Winetricks. - winetricks_url="https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks" - curl -sL ${winetricks_url} | install /dev/stdin /usr/local/bin/winetricks - - # Install AHK. - if (("$PROVISION_AHK")); then - echo "Installing AutoHotkey..." >&2 - su - $user -c " - set -x - export DISPLAY=:1.0 - export WINEDLLOVERRIDES=mscoree,mshtml= - echo \$DISPLAY - xdpyinfo &>/dev/null || (! pgrep -a Xvfb && Xvfb \$DISPLAY -screen 0 1024x768x16) & - wineboot -i - wget -qP /tmp -nc 'https://github.com/Lexikos/AutoHotkey_L/releases/download/v1.1.30.01/AutoHotkey_1.1.30.01_setup.exe' && \ - wine64 /tmp/AutoHotkey_*.exe /S /D='C:\\Apps\\AHK' && \ - rm -v /tmp/AutoHotkey_*.exe && \ - (pkill Xvfb || true) - " - ahk_path=$(su - $user -c 'winepath -u "C:\\Apps\\AHK"') - if [ -d "$ahk_path" ]; then - echo "AutoHotkey installed successfully!" >&2 - else - echo "Error: AutoHotkey installation failed!" >&2 - exit 1 - fi - fi + # Install platform. + ansible-playbook -i "localhost," -c local /opt/ansible/mt-install.yml -v # Install Charles proxy. if (("$PROVISION_CHARLES")); then @@ -255,6 +191,9 @@ case "$(uname -s)" in # Erase downloaded archive files. apt-get clean + # Clean up. + find /var/lib/apt/lists -type f -delete && \ + find /tmp -mindepth 1 '(' -type d -o -type f ')' -delete ;; Darwin) brew install git