Skip to content

Instantly share code, notes, and snippets.

@tinybug
Created July 7, 2019 14:44
Show Gist options
  • Save tinybug/4d37b5bd29fe13eedc106eb50f55ae20 to your computer and use it in GitHub Desktop.
Save tinybug/4d37b5bd29fe13eedc106eb50f55ae20 to your computer and use it in GitHub Desktop.
WASM - Emscripten Container Image
FROM debian:latest
MAINTAINER Robert Aboukhalil ([email protected])
# Main dependencies
RUN apt-get update && \
apt-get install -y git python build-essential openjdk-8-jre-headless
# Setup emsdk
RUN git clone https://github.com/emscripten-core/emsdk.git
WORKDIR /emsdk
RUN git pull
RUN ./emsdk install latest && \
./emsdk activate latest && \
./emsdk construct_env && \
echo ". /emsdk/emsdk_set_env.sh" >> ~/.bashrc && \
. ~/.bashrc && \
em++ --version
RUN mkdir /src
WORKDIR /src
# Book dependencies (putting those here so we don't rebuild scratch every time we add a dependency)
# Tools we'll use while building packages + OpenGL support + SDL2 support
RUN apt-get install -y \
procps gcc vim libz-dev autoconf libtool cmake \
libgles2-mesa-dev \
libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
# Setup & launch web server
ENV PORT 80
ENV WEB_SERVER_CODE "\
import SimpleHTTPServer, SocketServer \n\n\
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler): \n\
pass \n\n\
Handler.extensions_map['.wasm'] = 'application/wasm' \n\n\
print('Launching server on port {}...'.format($PORT)) \n\
httpd = SocketServer.TCPServer(('', $PORT), Handler) \n\
httpd.serve_forever()\n"
RUN echo "$WEB_SERVER_CODE" > /emsdk/server.py
CMD python /emsdk/server.py
# Export port
EXPOSE $PORT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment