Skip to content

Commit

Permalink
Improves installation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Jan 28, 2024
1 parent 8761ed8 commit be66e06
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 81 deletions.
24 changes: 13 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
79 changes: 9 additions & 70 deletions scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit be66e06

Please sign in to comment.