-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add MetaTrader-5 infrastructure
- Loading branch information
1 parent
b878f0b
commit 74b3780
Showing
22 changed files
with
5,034 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Deploy MetaTrader 5 Terminal (with RPYC API) | ||
|
||
# on: | ||
# workflow_dispatch: | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-images: | ||
name: build-images | ||
runs-on: ubuntu-latest | ||
env: | ||
BUILD_MODE: release | ||
|
||
steps: | ||
- name: Free disk space (Ubuntu) | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: true | ||
android: false | ||
dotnet: false | ||
haskell: false | ||
large-packages: true | ||
docker-images: true | ||
swap-storage: true | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GHCR | ||
uses: docker/login-action@v3.1.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.PACKAGES_TOKEN }} | ||
|
||
- name: Get branch name | ||
id: branch-name | ||
uses: tj-actions/branch-names@v8.0.1 | ||
|
||
- name: Build MetaTrader 5 Terminal image (latest) | ||
if: ${{ steps.branch-name.outputs.current_branch == 'main' }} | ||
id: mt5_build_latest | ||
uses: docker/build-push-action@v3 | ||
with: | ||
file: "infrastructure/MetaTrader5/Dockerfile" | ||
context: "infrastructure/MetaTrader5/" | ||
push: true | ||
tags: ghcr.io/${{ github.repository_owner }}/metatrader5-terminal:latest | ||
cache-from: type=gha | ||
cache-to: type=gha | ||
- name: Digest metatrader5-terminal image | ||
run: echo ${{ steps.mt5_build_latest.outputs.digest }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MT5_ACCOUNT_NUMBER=12345 | ||
MT5_PASSWORD=password | ||
MT5_SERVER=MetaTrader-Demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# FROM golang:1.14-buster AS novnc-build | ||
|
||
# WORKDIR /src | ||
|
||
# RUN go mod init build && \ | ||
# go get github.com/geek1011/easy-novnc@v1.1.0 && \ | ||
# go build -o /bin/easy-novnc github.com/geek1011/easy-novnc | ||
|
||
FROM tobix/pywine:3.9 | ||
|
||
# ---------------------------------------------------------------------------------------------- | ||
LABEL org.opencontainers.image.source=https://github.com/FortesenseLabs/metatrader-terminal | ||
LABEL org.opencontainers.image.description="Metatrader 5 Terminal (with RPYC API)" | ||
# ---------------------------------------------------------------------------------------------- | ||
|
||
# USER root | ||
ENV DISPLAY :0 | ||
# ENV USER=root | ||
# ENV PASSWORD=root | ||
ENV HOME=/root | ||
ENV SERVER_HOST='0.0.0.0' | ||
ENV SERVER_PORT=18812 | ||
ENV VNC_DESKTOP_NAME="Metatrader5" | ||
ENV VNC_GEOMETRY="1280x800" | ||
ENV DRIVE_C=${WINEPREFIX}/drive_c | ||
STOPSIGNAL SIGRTMIN+3 | ||
|
||
# MT5 Account Details | ||
ENV MT5_ACCOUNT_NUMBER='' | ||
ENV MT5_PASSWORD='' | ||
ENV MT5_SERVER='' | ||
|
||
# Install required packages | ||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends openbox tigervnc-standalone-server supervisor gosu && \ | ||
rm -rf /var/lib/apt/lists && \ | ||
mkdir -p /usr/share/desktop-directories | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y --no-install-recommends lxterminal nano openssh-client \ | ||
rsync xdg-utils htop \ | ||
tar xzip gzip bzip2 zip unzip wget && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists | ||
|
||
# COPY --from=novnc-build /bin/easy-novnc /usr/local/bin/ | ||
COPY assets/menu.xml /etc/xdg/openbox/ | ||
COPY assets/supervisord.conf /etc/ | ||
|
||
|
||
WORKDIR /$HOME/ | ||
COPY assets . | ||
|
||
RUN tar -xzf Metatrader-5.tar.gz -C "$DRIVE_C/" \ | ||
&& mv metatrader.desktop /usr/share/applications/ \ | ||
&& rm menu.xml supervisord.conf Metatrader-5.tar.gz | ||
|
||
RUN wine pip install -r requirements.txt \ | ||
&& chmod +x run_server.sh xtigervnc.sh easy-novnc.sh | ||
|
||
EXPOSE 5900 18812 | ||
# Used for debugs: | ||
# - tiger vnc server => 5900 | ||
# - easy-novnc => 8000 | ||
|
||
CMD ["supervisord"] | ||
|
||
# TODO: upgrade to wine >= 8 as wine 7 is unstable and unsupported by MT5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Metatrader 5 Terminal with RPYC API | ||
|
||
This Docker image provides a lightweight environment for running the Metatrader 5 Terminal with RPYC API access. It combines two base images: | ||
|
||
- `golang:1.14-buster`: Used to build the `easy-novnc` tool for remote desktop access. | ||
- `tobix/pywine:3.9`: Provides a Python environment with Wine for running the Metatrader 5 Terminal on Linux. [tobix/pywine:3.9](https://github.com/webcomics/pywine) | ||
|
||
## Features | ||
|
||
- Runs Metatrader 5 Terminal using Wine. | ||
- Enables access to the RPYC API for remote control. | ||
- Includes `easy-novnc` for optional remote desktop access (requires additional configuration) | ||
- Exposes ports for RPYC API (18812) and potential VNC (8000) | ||
|
||
## Usage | ||
|
||
1. **Build the image:** | ||
|
||
``` | ||
docker build -t metatrader5-terminal . | ||
``` | ||
|
||
2. **Run the container:** | ||
|
||
``` | ||
docker run -d --name metatrader5-terminal \ | ||
-p 18812:18812 \ | ||
-p 8000:8000 \ | ||
metatrader5-terminal | ||
``` | ||
|
||
This command runs the container in detached mode (`-d`) and maps the container's port 18812 to the host's port 18812 (`-p 18812:18812`). You can access the RPYC API from your host at `localhost:18812`. | ||
|
||
**Optional: Remote Desktop Access** | ||
|
||
This image includes `easy-novnc` for potential remote desktop access. However, additional configuration is needed outside the container, such as using a reverse proxy like Caddy. Refer to the following resources for setting up remote desktop access: | ||
|
||
- [https://www.digitalocean.com/community/tutorial-collections/how-to-set-up-a-remote-desktop-with-x2go](https://www.digitalocean.com/community/tutorial-collections/how-to-set-up-a-remote-desktop-with-x2go) | ||
- [https://github.com/gnzsnz/ib-gateway-docker/](https://github.com/gnzsnz/ib-gateway-docker/) | ||
|
||
**Additional notes:** | ||
|
||
- The container starts the `supervisord` process to manage services within the container. | ||
- The container utilizes the `gosu` user management tool. | ||
- Configuration files like `menu.xml` and `supervisord.conf` are copied into the container. | ||
|
||
## Environment Variables | ||
|
||
- `SERVER_HOST`: Hostname or IP address for RPYC API access (default: `0.0.0.0`). | ||
- `SERVER_PORT`: Port for RPYC API access (default: `18812`). | ||
|
||
## Dependencies | ||
|
||
- Requires Docker to be installed and running. | ||
|
||
## Contributing | ||
|
||
Feel free to submit pull requests for improvements or bug fixes. | ||
|
||
## License | ||
|
||
This image is licensed under the terms of the respective base image licenses (Golang and tobix/pywine). Please refer to their respective repositories for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
order webdav last | ||
} | ||
:8080 { | ||
log | ||
root * /data | ||
reverse_proxy mt5-app:8080 | ||
|
||
handle_path /files/* { | ||
file_server browse | ||
} | ||
redir /files /files/ | ||
|
||
handle /webdav/* { | ||
webdav { | ||
prefix /webdav | ||
} | ||
} | ||
redir /webdav /webdav/ | ||
|
||
basicauth /* { | ||
{env.APP_USERNAME} {env.APP_PASSWORD_HASH} | ||
} | ||
} |
Git LFS file not shown
Oops, something went wrong.