diff --git a/_web_server/Dockerfile b/_web_server/Dockerfile new file mode 100644 index 0000000..14cc402 --- /dev/null +++ b/_web_server/Dockerfile @@ -0,0 +1,36 @@ +# syntax=docker/dockerfile:1 +FROM ubuntu:22.10 +LABEL description="Verilog playground" + +# Prepare OS +RUN apt-get -y update \ + && apt-get -y install iverilog guile-3.0 locales git +RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \ + && locale-gen + +# Environment +ENV GIT_SSL_NO_VERIFY=1 +ENV GUILE_LOAD_PATH=/server/embddr-scheme-library +ENV LANG=en_US.UTF-8 +ENV DONOTUSEFIREJAIL=1 + +# Copy server files +WORKDIR /server +COPY server/* ./ +RUN git clone https://git.embddr.com/np/embddr-scheme-library.git +RUN mkdir play-work /verilog-playground-store + +EXPOSE 8080 +VOLUME /verilog-playground-store + +CMD [ "guile", "-e", "main", \ + "./playground-server.scm", \ + "--port=8080", \ + "--addr=0.0.0.0", \ + "--host=https://play.embddr.com", \ + "--iverilog-exe=./iverilog", \ + "--vvp-exe=./vvp", \ + "--max-len=10000", \ + "--work-base=play-work", \ + "--stor-base=/verilog-playground-store", \ + "--log-level=2" ] diff --git a/_web_server/container-create.sh b/_web_server/container-create.sh new file mode 100755 index 0000000..fcde7aa --- /dev/null +++ b/_web_server/container-create.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +docker build -t playground . diff --git a/_web_server/container-run.sh b/_web_server/container-run.sh new file mode 100755 index 0000000..e3d60e4 --- /dev/null +++ b/_web_server/container-run.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +if [ 0 -eq "$#" ]; then + echo "Usage $0 start/stop/status" + exit -1 +fi + +action=$1 +container=playground + +case $action in + "start") + cid=$(docker container ls -q -a -f name=$container) + + if [ -z "$cid" ]; then + docker run -d --name $container \ + -p 127.0.0.1:8089:8080 \ + -v /srv/playground/storage:/verilog-playground-store \ + --cpus=1 --memory=16g --memory-swap=16g \ + $container + else + docker start $container + fi + ;; + + "stop") + # Press twice CRTL-C + docker kill -s SIGINT $container + docker kill -s SIGINT $container + ;; + + "status") + cid=$(docker container ls -q -f name=$container) + + if [ -z "$cid" ]; then + echo "Stopped" + else + echo "Started" + fi + ;; + + "*") + echo "Unknown action $action. Actions start, stop and status are allowed" + ;; +esac