-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Feb 29, 2024
1 parent
6d6eddf
commit fba0b6a
Showing
14 changed files
with
850 additions
and
512 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 |
---|---|---|
@@ -1,70 +1,70 @@ | ||
# DOSBOX IN A CONTAINER WITH VNC CLIENT -- NOW WITH SOUND! | ||
|
||
So much fun! After 3 years, I decided to bite the bullet and figure out how to add sound... and now it has it. I completely overhauled the Dockerfile to use Suerpvisor to start the processes because there were simply too many after adding support for sound. The rest of it is similar to the original, which is in an archive folder in this repo. In any case, I hope you enjoy it! | ||
|
||
1. Clone the repo: `git clone https://github.com/theonemule/dos-game.git` | ||
1. Place a copy of your game in the folder. I am using the shareware version of Commander Keen here. | ||
1. Replace the `COPY keen /dos/keen` with your game (ie. COPY wolf3d /dos/wolf3d). 1. You can also change the default password or override it with a -e parameter when you run the image. | ||
1. Now, with Docker, build the image. I’m assuming you already have Docker installed and are somewhat familiar with it. CD to the directory in a console and run the command… | ||
```` | ||
docker build -t mydosbox . | ||
```` | ||
1. Run the image. | ||
```` | ||
docker run -p 6080:80 mydosbox | ||
```` | ||
|
||
1. Open a browser and point it to http://localhost:6080/vnc.html | ||
1. You should see a prompt for the password. Type it in, and you should be able to connect to your container with DosBox running. The game is started automatically. | ||
1. Once your image is built, you can push it to your image repository with docker push, but you’ll need to tag it appropriately. | ||
|
||
# USE WITH KUBERNETES | ||
Kubernetes is another part of the equation when it comes to container apps. Containers on Kubernetes are deployed into pods, which are then usually a part of a deployment with one or more pods associated. Deployments can also be used to create scalable sets of pods for high availability on a Kubernetes cluster. If you’re unfamiliar with Kubernetes, check out this webinar below, where I go in-depth. | ||
|
||
Deployments and services can be defined declaratively with a YAML file. Below is a Kubernetes YAML file that defines a deployment and a service for my retro gaming container. | ||
|
||
The deployment is simple – it points to a single container image called blaize/keen and then tells Kubernetes what ports to expose for the container. The service defines how the deployment will be exposed on a network. In this case, it’s using a TCP load balancer, exposing port 80 and mapping that to the port exposed by the deployment. The service uses selectors on the label app to match the service with the deployment. | ||
|
||
```` | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: keen-service | ||
labels: | ||
app: keen-deployment | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 6080 | ||
selector: | ||
app: keen-deployment | ||
type: LoadBalancer | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: keen-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: keen-deployment | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: keen-deployment | ||
spec: | ||
containers: | ||
- name: master | ||
image: blaize/keen | ||
ports: | ||
- containerPort: 80 | ||
```` | ||
|
||
To connect, use this, first create a file called keen.yaml file, configure your instance kubectl to work with your instance of Kubernetes, then run deploy the sample. | ||
|
||
```` | ||
kubectl create -f keen.yaml | ||
```` | ||
|
||
When this is deployed to Kubernetes, Kubernetes will configure the external network to open on port 80 to listen to incoming requests. When used on Azure Kubernetes Services, AKS will create and map a public IP address (htttp://[your ip address]/vnc.html) for the service. Once connected, you can point your browser to the IP address of your cluster and have fun playing your retro games! | ||
# DOSBOX IN A CONTAINER WITH VNC CLIENT -- NOW WITH SOUND! | ||
|
||
So much fun! After 3 years, I decided to bite the bullet and figure out how to add sound... and now it has it. I completely overhauled the Dockerfile to use Suerpvisor to start the processes because there were simply too many after adding support for sound. The rest of it is similar to the original, which is in an archive folder in this repo. In any case, I hope you enjoy it! | ||
|
||
1. Clone the repo: `git clone https://github.com/theonemule/dos-game.git` | ||
1. Place a copy of your game in the folder. I am using the shareware version of Commander Keen here. | ||
1. Replace the `COPY keen /dos/keen` with your game (ie. COPY wolf3d /dos/wolf3d). 1. You can also change the default password or override it with a -e parameter when you run the image. | ||
1. Now, with Docker, build the image. I’m assuming you already have Docker installed and are somewhat familiar with it. CD to the directory in a console and run the command… | ||
```` | ||
docker build -t mydosbox . | ||
```` | ||
1. Run the image. | ||
```` | ||
docker run -p 6080:80 mydosbox | ||
```` | ||
|
||
1. Open a browser and point it to http://localhost:6080/vnc.html | ||
1. You should see a prompt for the password. Type it in, and you should be able to connect to your container with DosBox running. The game is started automatically. | ||
1. Once your image is built, you can push it to your image repository with docker push, but you’ll need to tag it appropriately. | ||
|
||
# USE WITH KUBERNETES | ||
Kubernetes is another part of the equation when it comes to container apps. Containers on Kubernetes are deployed into pods, which are then usually a part of a deployment with one or more pods associated. Deployments can also be used to create scalable sets of pods for high availability on a Kubernetes cluster. If you’re unfamiliar with Kubernetes, check out this webinar below, where I go in-depth. | ||
|
||
Deployments and services can be defined declaratively with a YAML file. Below is a Kubernetes YAML file that defines a deployment and a service for my retro gaming container. | ||
|
||
The deployment is simple – it points to a single container image called blaize/keen and then tells Kubernetes what ports to expose for the container. The service defines how the deployment will be exposed on a network. In this case, it’s using a TCP load balancer, exposing port 80 and mapping that to the port exposed by the deployment. The service uses selectors on the label app to match the service with the deployment. | ||
|
||
```` | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: keen-service | ||
labels: | ||
app: keen-deployment | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 6080 | ||
selector: | ||
app: keen-deployment | ||
type: LoadBalancer | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: keen-deployment | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: keen-deployment | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: keen-deployment | ||
spec: | ||
containers: | ||
- name: master | ||
image: blaize/keen | ||
ports: | ||
- containerPort: 80 | ||
```` | ||
|
||
To connect, use this, first create a file called keen.yaml file, configure your instance kubectl to work with your instance of Kubernetes, then run deploy the sample. | ||
|
||
```` | ||
kubectl create -f keen.yaml | ||
```` | ||
|
||
When this is deployed to Kubernetes, Kubernetes will configure the external network to open on port 80 to listen to incoming requests. When used on Azure Kubernetes Services, AKS will create and map a public IP address (htttp://[your ip address]/vnc.html) for the service. Once connected, you can point your browser to the IP address of your cluster and have fun playing your retro games! |
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 |
---|---|---|
@@ -1,41 +1,41 @@ | ||
FROM ubuntu:22.04 | ||
ENV USER=root | ||
ENV PASSWORD=password1 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN=true | ||
COPY keen /dos/keen | ||
RUN apt-get update && \ | ||
echo "tzdata tzdata/Areas select America" > ~/tx.txt && \ | ||
echo "tzdata tzdata/Zones/America select New York" >> ~/tx.txt && \ | ||
debconf-set-selections ~/tx.txt && \ | ||
apt-get install -y curl tightvncserver ratpoison dosbox novnc websockify bzip2 gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-tools libglu1-mesa libgtk2.0-0 libncursesw5 libopenal1 libsdl-image1.2 libsdl-ttf2.0-0 libsdl1.2debian libsndfile1 pulseaudio supervisor ucspi-tcp wget | ||
|
||
COPY default.pa client.conf /etc/pulse/ | ||
COPY webaudio.js /usr/share/novnc/core/ | ||
|
||
RUN ln -s /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html \ | ||
&& sed -i 's/display:flex/display:none/' /usr/share/novnc/app/styles/lite.css \ | ||
&& sed -i "/import RFB/a \ | ||
import WebAudio from './core/webaudio.js'" \ | ||
/usr/share/novnc/vnc_lite.html \ | ||
&& sed -i "/function connected(e)/a \ | ||
var wa = new WebAudio('ws://10.0.1.92:8081/websockify'); \ | ||
document.getElementsByTagName('canvas')[0].addEventListener('keydown', e => { wa.start(); });" \ | ||
/usr/share/novnc/vnc_lite.html | ||
|
||
RUN mkdir ~/.vnc/ && \ | ||
mkdir ~/.dosbox && \ | ||
echo $PASSWORD | vncpasswd -f > ~/.vnc/passwd && \ | ||
chmod 0600 ~/.vnc/passwd && \ | ||
echo "set border 0" > ~/.ratpoisonrc && \ | ||
echo "exec dosbox -conf ~/.dosbox/dosbox.conf -fullscreen -c 'MOUNT C: /dos' -c 'C:' -c 'cd keen' -c 'keen1'">> ~/.ratpoisonrc && \ | ||
export DOSCONF=$(dosbox -printconf) && \ | ||
cp $DOSCONF ~/.dosbox/dosbox.conf && \ | ||
sed -i 's/usescancodes=true/usescancodes=false/' ~/.dosbox/dosbox.conf && \ | ||
openssl req -x509 -nodes -newkey rsa:2048 -keyout ~/novnc.pem -out ~/novnc.pem -days 3650 -subj "/C=US/ST=NY/L=NY/O=NY/OU=NY/CN=NY emailAddress=email@example.com" | ||
EXPOSE 80 | ||
|
||
COPY supervisord.conf /etc/supervisor/supervisord.conf | ||
ENTRYPOINT [ "supervisord", "-c", "/etc/supervisor/supervisord.conf" ] | ||
|
||
# CMD vncserver && websockify -D --web=/usr/share/novnc/ --cert=~/novnc.pem 80 localhost:5901 && tail -f /dev/null | ||
FROM ubuntu:22.04 | ||
ENV USER=root | ||
ENV PASSWORD=password1 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN=true | ||
COPY keen /dos/keen | ||
RUN apt-get update && \ | ||
echo "tzdata tzdata/Areas select America" > ~/tx.txt && \ | ||
echo "tzdata tzdata/Zones/America select New York" >> ~/tx.txt && \ | ||
debconf-set-selections ~/tx.txt && \ | ||
apt-get install -y curl tightvncserver ratpoison dosbox novnc websockify bzip2 gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-tools libglu1-mesa libgtk2.0-0 libncursesw5 libopenal1 libsdl-image1.2 libsdl-ttf2.0-0 libsdl1.2debian libsndfile1 pulseaudio supervisor ucspi-tcp wget | ||
COPY default.pa client.conf /etc/pulse/ | ||
COPY webaudio.js /usr/share/novnc/core/ | ||
RUN ln -s /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html \ | ||
&& sed -i 's/display:flex/display:none/' /usr/share/novnc/app/styles/lite.css \ | ||
&& sed -i "/import RFB/a \ | ||
import WebAudio from './core/webaudio.js'" \ | ||
/usr/share/novnc/vnc_lite.html \ | ||
&& sed -i "/function connected(e)/a \ | ||
var wa = new WebAudio('ws://10.0.1.92:8081/websockify'); \ | ||
document.getElementsByTagName('canvas')[0].addEventListener('keydown', e => { wa.start(); });" \ | ||
/usr/share/novnc/vnc_lite.html | ||
RUN mkdir ~/.vnc/ && \ | ||
mkdir ~/.dosbox && \ | ||
echo $PASSWORD | vncpasswd -f > ~/.vnc/passwd && \ | ||
chmod 0600 ~/.vnc/passwd && \ | ||
echo "set border 0" > ~/.ratpoisonrc && \ | ||
echo "exec dosbox -conf ~/.dosbox/dosbox.conf -fullscreen -c 'MOUNT C: /dos' -c 'C:' -c 'cd keen' -c 'keen1'">> ~/.ratpoisonrc && \ | ||
export DOSCONF=$(dosbox -printconf) && \ | ||
cp $DOSCONF ~/.dosbox/dosbox.conf && \ | ||
sed -i 's/usescancodes=true/usescancodes=false/' ~/.dosbox/dosbox.conf && \ | ||
openssl req -x509 -nodes -newkey rsa:2048 -keyout ~/novnc.pem -out ~/novnc.pem -days 3650 -subj "/C=US/ST=NY/L=NY/O=NY/OU=NY/CN=NY emailAddress=email@example.com" | ||
EXPOSE 80 | ||
COPY supervisord.conf /etc/supervisor/supervisord.conf | ||
ENTRYPOINT [ "supervisord", "-c", "/etc/supervisor/supervisord.conf" ] | ||
# CMD vncserver && websockify -D --web=/usr/share/novnc/ --cert=~/novnc.pem 80 localhost:5901 && tail -f /dev/null |
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 |
---|---|---|
@@ -1 +1 @@ | ||
default-server=unix:/tmp/pulseaudio.socket | ||
default-server=unix:/tmp/pulseaudio.socket |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/usr/bin/pulseaudio -nF | ||
load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1 | ||
load-module module-always-sink | ||
#!/usr/bin/pulseaudio -nF | ||
load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1 | ||
load-module module-always-sink |
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 |
---|---|---|
@@ -1,68 +1,56 @@ | ||
FROM ubuntu:22.04 | ||
|
||
#User Settings for VNC | ||
ENV USER=root | ||
ENV PASSWORD=password1 | ||
|
||
#Variables for installation | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN=true | ||
ENV XKB_DEFAULT_RULES=base | ||
|
||
#Install dependencies | ||
RUN apt-get update && \ | ||
echo "tzdata tzdata/Areas select America" > ~/tx.txt && \ | ||
echo "tzdata tzdata/Zones/America select New York" >> ~/tx.txt && \ | ||
debconf-set-selections ~/tx.txt && \ | ||
apt-get install -y unzip gnupg apt-transport-https wget software-properties-common ratpoison novnc websockify libxv1 libglu1-mesa xauth x11-utils xorg tightvncserver libegl1-mesa xauth x11-xkb-utils software-properties-common bzip2 gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-tools libglu1-mesa libgtk2.0-0 libncursesw5 libopenal1 libsdl-image1.2 libsdl-ttf2.0-0 libsdl1.2debian libsndfile1 nginx pulseaudio supervisor ucspi-tcp wget build-essential ccache dosbox | ||
|
||
#Copy the files for audio and NGINX | ||
COPY default.pa client.conf /etc/pulse/ | ||
COPY nginx.conf /etc/nginx/ | ||
COPY webaudio.js /usr/share/novnc/core/ | ||
|
||
#Inject code for audio in the NoVNC client | ||
RUN sed -i "/import RFB/a \ | ||
import WebAudio from '/core/webaudio.js'" \ | ||
/usr/share/novnc/app/ui.js \ | ||
&& sed -i "/UI.rfb.resizeSession/a \ | ||
var loc = window.location, new_uri; \ | ||
if (loc.protocol === 'https:') { \ | ||
new_uri = 'wss:'; \ | ||
} else { \ | ||
new_uri = 'ws:'; \ | ||
} \ | ||
new_uri += '//' + loc.host; \ | ||
new_uri += '/audio'; \ | ||
var wa = new WebAudio(new_uri); \ | ||
document.addEventListener('keydown', e => { wa.start(); });" \ | ||
/usr/share/novnc/app/ui.js | ||
|
||
#Install VirtualGL and TurboVNC | ||
RUN wget https://gigenet.dl.sourceforge.net/project/virtualgl/3.1/virtualgl_3.1_amd64.deb && \ | ||
wget https://zenlayer.dl.sourceforge.net/project/turbovnc/3.0.3/turbovnc_3.0.3_amd64.deb && \ | ||
dpkg -i virtualgl_*.deb && \ | ||
dpkg -i turbovnc_*.deb | ||
|
||
|
||
# Configure DOSBOX | ||
RUN mkdir ~/.vnc/ && \ | ||
mkdir ~/.dosbox && \ | ||
echo $PASSWORD | vncpasswd -f > ~/.vnc/passwd && \ | ||
chmod 0600 ~/.vnc/passwd && \ | ||
echo "set border 0" > ~/.ratpoisonrc && \ | ||
echo "exec dosbox -conf ~/.dosbox/dosbox.conf -fullscreen -c 'MOUNT C: /dos' -c 'C:' -c 'cd keen' -c 'keen1'">> ~/.ratpoisonrc && \ | ||
export DOSCONF=$(dosbox -printconf) && \ | ||
cp $DOSCONF ~/.dosbox/dosbox.conf && \ | ||
sed -i 's/usescancodes=true/usescancodes=false/' ~/.dosbox/dosbox.conf && \ | ||
openssl req -x509 -nodes -newkey rsa:2048 -keyout ~/novnc.pem -out ~/novnc.pem -days 3650 -subj "/C=US/ST=NY/L=NY/O=NY/OU=NY/CN=NY emailAddress=email@example.com" | ||
|
||
|
||
COPY keen /dos/keen | ||
COPY doom /dos/doom | ||
|
||
EXPOSE 80 | ||
|
||
#Copy in supervisor configuration for startup | ||
COPY supervisord.conf /etc/supervisor/supervisord.conf | ||
ENTRYPOINT [ "supervisord", "-c", "/etc/supervisor/supervisord.conf" ] | ||
FROM ubuntu:22.04 | ||
|
||
#User Settings for VNC | ||
ENV USER=root | ||
ENV PASSWORD=password1 | ||
|
||
#Variables for installation | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN=true | ||
ENV XKB_DEFAULT_RULES=base | ||
|
||
#Install dependencies | ||
RUN apt-get update && \ | ||
echo "tzdata tzdata/Areas select America" > ~/tx.txt && \ | ||
echo "tzdata tzdata/Zones/America select New York" >> ~/tx.txt && \ | ||
debconf-set-selections ~/tx.txt && \ | ||
apt-get install -y unzip gnupg apt-transport-https wget software-properties-common novnc websockify libxv1 libglu1-mesa xauth x11-utils xorg tightvncserver libegl1-mesa xauth x11-xkb-utils software-properties-common bzip2 gstreamer1.0-plugins-good gstreamer1.0-pulseaudio gstreamer1.0-tools libglu1-mesa libgtk2.0-0 libncursesw5 libopenal1 libsdl-image1.2 libsdl-ttf2.0-0 libsdl1.2debian libsndfile1 nginx pulseaudio supervisor ucspi-tcp wget build-essential ccache dosbox | ||
|
||
RUN mkdir ~/.vnc && \ | ||
mkdir ~/.dosbox | ||
|
||
#Copy the files for audio and NGINX | ||
COPY default.pa client.conf /etc/pulse/ | ||
COPY nginx.conf /etc/nginx/ | ||
COPY webaudio.js /usr/share/novnc/core/ | ||
COPY dosbox.conf /root/.dosbox/dosbox.conf | ||
COPY xstartup /root/.vnc/xstartup | ||
|
||
#Inject code for audio in the NoVNC client | ||
RUN sed -i "/import RFB/a \ | ||
import WebAudio from '/core/webaudio.js'" \ | ||
/usr/share/novnc/app/ui.js \ | ||
&& sed -i "/UI.rfb.resizeSession/a \ | ||
var loc = window.location, new_uri; \ | ||
if (loc.protocol === 'https:') { \ | ||
new_uri = 'wss:'; \ | ||
} else { \ | ||
new_uri = 'ws:'; \ | ||
} \ | ||
new_uri += '//' + loc.host; \ | ||
new_uri += '/audio'; \ | ||
var wa = new WebAudio(new_uri); \ | ||
document.addEventListener('keydown', e => { wa.start(); });" \ | ||
/usr/share/novnc/app/ui.js | ||
|
||
RUN echo $PASSWORD | vncpasswd -f > ~/.vnc/passwd && \ | ||
chmod 0600 ~/.vnc/passwd | ||
|
||
COPY keen /dos/keen | ||
COPY doom /dos/doom | ||
|
||
EXPOSE 80 | ||
|
||
#Copy in supervisor configuration for startup | ||
COPY supervisord.conf /etc/supervisor/supervisord.conf | ||
ENTRYPOINT [ "supervisord", "-c", "/etc/supervisor/supervisord.conf" ] |
Oops, something went wrong.