Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Build and Push Docker Image

on:
push:
branches: [ main ]
paths:
- 'docker/**'

pull_request:
branches: [ main ]
paths:
- 'docker/**'

release:
types: [ published ]
workflow_dispatch:
inputs:
manual_push:
description: 'Set to "yes" to push tag :test image to GHCR for testing before merging to main'
required: false
default: 'no'
type: choice
options:
- 'no'
- 'yes'

jobs:

build-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Build Docker image
run: |
DOCKER_URI=tos-webtop docker build -f ./docker/Dockerfile -t tos-webtop:test ./docker

- name: Test Docker image
run: |
docker run --rm tos-webtop:test > /tmp/test.log &
sleep 60

# if grep -q "Data WebSocket Server listening on port 8082" /tmp/test.log; then
# echo "Build successful"
# else
# echo "Build failed!"
# exit 1
# fi

push-to-ghcr:
runs-on: ubuntu-latest
# Run if on main branch, or if manual_push is yes from workflow_dispatch
if: >-
(github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.manual_push == 'yes')
needs: build-test
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# 👆 This is needed ARM emulation on AMD64 runner

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 👆 This is need for QEMU to work

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set lowercase repository name
run: |
echo "LOWERCASE_REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV

- name: Set IMAGE_TAG for build-test
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.manual_push }}" = "yes" ]; then
echo "IMAGE_TAG=test" >> $GITHUB_ENV
elif [ "${{ github.ref }}" = "refs/heads/main" ]; then
echo "IMAGE_TAG=latest" >> $GITHUB_ENV
fi

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ env.LOWERCASE_REPO }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./docker
platforms: linux/amd64,linux/arm64
file: ./docker/Dockerfile
push: true
tags: |
ghcr.io/${{ env.LOWERCASE_REPO }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ env.LOWERCASE_REPO }}:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
11 changes: 0 additions & 11 deletions Dockerfile

This file was deleted.

6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ BACKUP_DIR=./backup
download-thinkswim-installer:
curl -O https://tosmediaserver.schwab.com/installer/InstFiles/thinkorswim_installer.sh

install-dev-dependencies:
sudo apt-get update
sudo apt-get install -y expect openjdk-21-jre

start:
docker compose up -d
docker compose logs -f
Expand Down Expand Up @@ -60,4 +64,4 @@ restore:
docker compose up -d

docker-build:
docker build -t $(DOCKER_IMAGE_NAME) .
docker build -t $(DOCKER_IMAGE_NAME) -f ./docker/Dockerfile ./docker
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: tos-webtop
services:
webtop:
# Uses the specific Ubuntu-based MATE tag from LinuxServer.io
image: tos-webtop:latest
image: ${DOCKER_URI:-ghcr.io/gitricko/tos-webtop:latest}
container_name: webtop-mate

# Optional: Needed for some modern GUI apps to function properly on older hosts/kernels
Expand Down Expand Up @@ -46,4 +46,4 @@ networks:
volumes:
tos-webtop-config:
external: false
name: tos-webtop-config
name: tos-webtop-config
18 changes: 18 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM lscr.io/linuxserver/webtop:ubuntu-mate

# Install OpenJDK 21 (or your required version)
RUN sudo apt-get update && \
sudo apt-get install -y openjdk-21-jre expect && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/*

# Add ThinkSwim installer
RUN curl -o /tmp/thinkorswim_installer.sh https://tosmediaserver.schwab.com/installer/InstFiles/thinkorswim_installer.sh
RUN chmod +x /tmp/thinkorswim_installer.sh

# Automate ThinkOrSwim installation
ADD thinkorswim_expect_script.sh /tmp
RUN chmod +x /tmp/thinkorswim_expect_script.sh
ADD tos.desktop /etc/xdg/autostart
RUN sudo chmod +x /etc/xdg/autostart/tos.desktop
# RUN sudo chown 1000:1000 /etc/xdg/autostart/tos.desktop
69 changes: 69 additions & 0 deletions docker/thinkorswim_expect_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/expect -f

# Set a timeout for commands (in seconds)
set timeout 5

# The path to your installer script
set INSTALLER_SCRIPT "/tmp/thinkorswim_installer.sh"
set FOLDER_PATH "/config/thinkorswim"

# Use Tcl's 'file exist' command to check if the path exists AND
# 'file isdirectory' to ensure it is specifically a directory.
if {[file exist $FOLDER_PATH] && [file isdirectory $FOLDER_PATH]} {
# The folder exists and is a directory. Exit the script.
puts "ToS Desktop is already installed. Exiting script."
exit 0
} else {
puts "ToS Desktop is not installed. Proceeding with installation."
}

# 1. Start the installer in console mode (-c)
spawn sh $INSTALLER_SCRIPT -c

# 2. Respond to "Please select a language:"
# Expected: "3: English [Enter]"
expect "\[1 - 3\]"
send "3\r"

# 3. Respond to "OK [o, Enter], Cancel [c]"
# Expected: "OK [o, Enter]"
expect "Cancel \[c\]"
send "o\r"

# 4. Respond to "Please select your account provider"
# Expected: "Schwab [1, Enter]"
expect "thinkorswim Guest Pass - 30 days trial account \[2\]"
send "1\r"

# 5. Respond to "I acknowledge, continue with installation. [1], I do not agree; cancel installation. [2, Enter]"
# Expected: "I acknowledge, continue with installation. [1]"
expect "\[2, Enter\]"
send "1\r"

# 6. Respond to "For which users shall thinkorswim be installed?"
# Expected: "Install for all users of this machine [2]"
expect "Install for all users of this machine \[2\]"
send "2\r"

# 7. Respond to "Where should thinkorswim be installed?"
# Expected: "[/config/thinkorswim]" and custom path /tmp/thinkorswim
expect "\[/config/thinkorswim\]"
send "/config/thinkorswim\r"

# 8. Respond to "Create desktop icon?"
# Expected: "Yes [y, Enter]"
expect "No \[n\]"
send "\r"

# Wait for the "Extracting files ..." and "Setup has finished" lines
expect "Setup has finished installing thinkorswim on your computer."

# 9. Respond to "Run thinkorswim?"
# Expected: "No [n]"
expect "No \[n\]"
send "y\r"

# Wait for the script to finish and the prompt to return
expect eof

puts "ToS Desktop installation done..."
9 changes: 9 additions & 0 deletions docker/tos.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Type=Application
Exec=bash -c "/tmp/thinkorswim_expect_script.sh > /tmp/tos-install.log"
Hidden=false
Name[en_US]=ToS Desktop Installer
Name=ToS Desktop Installer
Comment[en_US]=Install ToS Desktop if it has not installed
Comment=Install ToS Desktop if it has not installed
X-MATE-Autostart-Delay=0