-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David Young <[email protected]>
- Loading branch information
1 parent
a96fc52
commit 877bb69
Showing
8 changed files
with
102 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM alpine as cloner | ||
ARG VERSION | ||
RUN apk add --update --no-cache tmux ttyd git && \ | ||
git clone -b $VERSION https://github.com/westsurname/scripts.git /source | ||
|
||
FROM python:3.9-slim | ||
|
||
ARG SERVICE_NAME=blackhole | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy only the files needed for pip install to maximize cache utilization | ||
COPY --from=cloner /source/requirements.txt ./ | ||
|
||
# Install Python dependencies | ||
RUN grep -E "#.*($SERVICE_NAME|all)" requirements.txt | awk '{print $0}' > service_requirements.txt && \ | ||
pip install --no-cache-dir -r service_requirements.txt | ||
|
||
# Copy the rest of the application | ||
COPY --from=cloner /source/. . | ||
|
||
CMD ["python", "blackhole_watcher.py"] | ||
|
||
# Add tmux | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
tmux | ||
|
||
# Add ttyd | ||
ADD --chmod=755 https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64 /usr/local/bin/ttyd | ||
|
||
COPY --chown=568:568 apps/wests-blackhole-script/blackhole.sh / | ||
COPY --chown=568:568 apps/wests-blackhole-script/launch-tmux.sh / | ||
COPY --chown=568:568 apps/wests-blackhole-script/entrypoint.sh / | ||
COPY --chown=568:568 apps/wests-blackhole-script/restricted.tmux.conf / | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
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,4 @@ | ||
#!/bin/bash | ||
|
||
cd /app | ||
python blackhole_watcher.py |
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,5 @@ | ||
--- | ||
# https://github.com/aelsabbahy/goss/blob/master/docs/manual.md#process | ||
process: | ||
python3: | ||
running: true |
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,4 @@ | ||
#!/usr/bin/env bash | ||
version=$(curl -sX GET https://api.github.com/repos/westsurname/scripts/releases/latest --header "Authorization: Bearer ${TOKEN}" | jq --raw-output '. | .tag_name') | ||
version="${version#*release-}" | ||
printf "%s" "${version}" |
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,11 @@ | ||
#!/bin/bash | ||
|
||
# Start riven in the background | ||
tmux -f /restricted.tmux.conf new-session -x 80 -y 24 -A -d -s blackhole /blackhole.sh | ||
|
||
# Prepare a tmux entry to the already-running process, use solarized dark colors | ||
ttyd -p 3001 -W \ | ||
-t titleFixed='Blackhole | ElfHosted' \ | ||
-t 'theme={"background": "#1c1c1c", "brightGreen": "#585858", "blue": "#0087ff", "black": "#262626", "brightBlack": "#1c1c1c", "brightBlue": "#808080", "brightCyan": "#8a8a8a", "brightMagenta": "#5f5faf", "brightRed": "#d75f00", "brightWhite": "#ffffd7", "brightYellow": "#626262", "cyan": "#00afaf", "green": "#5f8700", "magenta": "#af005f", "red": "#d70000", "white": "#e4e4e4", "yellow": "#af8700"}' \ | ||
-t drawBoldTextInBrightColors=false \ | ||
/launch-tmux.sh |
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,4 @@ | ||
#!/bin/bash | ||
|
||
tmux -f /restricted.tmux.conf new-session -A -s blackhole /blackhole.sh | ||
|
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,17 @@ | ||
{ | ||
"app": "wests-blackhole-script", | ||
"base": false, | ||
"channels": [ | ||
{ | ||
"name": "main", | ||
"platforms": [ | ||
"linux/amd64" | ||
], | ||
"stable": true, | ||
"tests": { | ||
"enabled": false, | ||
"type": "web" | ||
} | ||
} | ||
] | ||
} |
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,19 @@ | ||
# Always launch PD | ||
set -g default-command "/blackhole.sh" | ||
|
||
# "lock down" tmux | ||
unbind C-b | ||
unbind % | ||
unbind '"' | ||
unbind c | ||
set -g mouse off | ||
|
||
# Disable status bar | ||
set -g status off | ||
|
||
# Disable special characters on scrolling | ||
set -g terminal-overrides 'xterm*:smcup@:rmcup@' | ||
|
||
# resize as requested | ||
# set -g window-size latest | ||
setw -g aggressive-resize on |