EA31337 / EA-Tester

šŸ³šŸ“ˆ Headless Forex backtesting for MetaTrader platform using Docker
https://ea31337.github.io/EA-Tester
MIT License
108 stars 84 forks source link

docker build -- correct workdir? #223

Closed missinglink closed 1 year ago

missinglink commented 1 year ago

Heya,

When running the make docker-build there is an error executing provision.sh. The CWD is WORKDIR /home/ubuntu and the file is copied to /opt/scripts.

I was going to fiddle around and change the WORKDIR but thought maybe it's an error on my part?

make docker-build
docker build -t ea-tester:latest --build-arg BUILD_DATE=2023-01-28T11:32:45Z --build-arg VCS_REF=e0bb13a --build-arg VERSION=latest .
[+] Building 1.7s (10/17)
 => [internal] load build definition from Dockerfile                               0.0s
 => => transferring dockerfile: 2.56kB                                             0.0s
 => [internal] load .dockerignore                                                  0.0s
 => => transferring context: 2B                                                    0.0s
 => [internal] load metadata for docker.io/library/ubuntu:xenial                   1.4s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                      0.0s
 => [internal] load build context                                                  0.0s
 => => transferring context: 5.64kB                                                0.0s
 => [ubuntu-base 1/3] FROM docker.io/library/ubuntu:xenial@sha256:1f1a2d56de1d604  0.0s
 => CACHED [ubuntu-base 2/3] RUN useradd -rm -d /home/ubuntu -s /bin/bash -g root  0.0s
 => CACHED [ubuntu-base 3/3] WORKDIR /home/ubuntu                                  0.0s
 => CACHED [ubuntu-provisioned 1/3] COPY scripts /opt/scripts                      0.0s
 => ERROR [ubuntu-provisioned 2/3] RUN provision.sh                                0.2s
------
 > [ubuntu-provisioned 2/3] RUN provision.sh:
#10 0.203 Error: This script needs to be run within container.
------
executor failed running [/bin/sh -c provision.sh]: exit code: 1
make: *** [docker-build] Error 1
git log -1
commit e0bb13a082991130821ec74b30d54ec6cad1b8a6 (HEAD -> master, origin/master, origin/dev, origin/HEAD)
Author: kenorb <kenorb@users.noreply.github.com>
Date:   Wed Aug 3 23:41:47 2022 +0100

    README: Fixes issues with named links
missinglink commented 1 year ago

Agh so it seems that provision.sh can only be run in a CI env, I'd like to run this locally in docker running locally, is that possible?

kenorb commented 1 year ago

Agh so it seems that provision.sh can only be run in a CI env, I'd like to run this ~locally~ in docker running locally, is that possible?

Yes, it's designed to be run in some local environment, as it's installing a lot of libraries. It's to avoid breaking or polluting your real environment. I've tested provision.sh script in Docker containers, Vagrant, CI/CD such as GitHub Actions, Travis or even in Colab.

If you want to run it on some machine, you still can, but you need to workaround these conditions: https://github.com/EA31337/EA-Tester/blob/v1.0.4/scripts/provision.sh#L39-L44

missinglink commented 1 year ago

Thanks, the following change allowed me to execute make docker-build:

diff --git a/Dockerfile b/Dockerfile
index 1455562..4f454db 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -20,6 +20,7 @@ ARG PROVISION_MONO=0
 ARG PROVISION_SSH=0
 ARG PROVISION_SUDO=1
 ARG PROVISION_VNC=1
+ARG CI=1

 # Provision container image.
 COPY scripts /opt/scripts