Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create initial dockerfile #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ubuntu:22.04

ENV TZ=Etc/UTC
ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt-get install -y python3 build-essential libffi-dev git curl wget zlib1g-dev zip unzip

RUN apt-get install -y gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
lzma lzma-dev tk-dev uuid-dev zlib1g-dev

RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 20 && \
update-alternatives --config python

COPY . /root/vial-web

WORKDIR /root/vial-web

RUN git clone https://github.com/vial-kb/vial-gui.git
RUN git clone https://github.com/vial-kb/via-keymap-precompiled.git

RUN echo 'source "/root/vial-web/emsdk/emsdk_env.sh"' >> $HOME/.bash_profile

RUN ./fetch-emsdk.sh
RUN ./fetch-deps.sh
RUN ./build-deps.sh

WORKDIR /root/vial-web/src
RUN ./build.sh

COPY ./http-server-cors.py /root/vial-web/src/build/http-server-cors.py

WORKDIR /root/vial-web/src/build

CMD /usr/bin/python http-server-cors.py
EXPOSE 8000
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@ git clone https://github.com/vial-kb/via-keymap-precompiled.git
cd src
./build.sh
```


## Docker build

```
git clone https://github.com/vial-kb/vial-web.git
cd vial-web

docker build -t localrun/vial-web .

# once build is complete
docker run --rm -d -p 8000:8000 localrun/vial-web

# open browser to http://localhost:8000

```
23 changes: 23 additions & 0 deletions http-server-cors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python

# Attribution: https://stackoverflow.com/questions/21956683/enable-access-control-on-simple-http-server

try:
# Python 3
from http.server import HTTPServer, SimpleHTTPRequestHandler, test as test_orig
import sys
def test (*args):
test_orig(*args, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)
except ImportError: # Python 2
from BaseHTTPServer import HTTPServer, test
from SimpleHTTPServer import SimpleHTTPRequestHandler

class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
SimpleHTTPRequestHandler.end_headers(self)

if __name__ == '__main__':
test(CORSRequestHandler, HTTPServer)