Added dockerfiles form trzeci/emscripten-docker (#368)

As a continuation from: https://github.com/emscripten-core/emscripten/issues/8742

This PR provides adopted Dockerfile from https://github.com/trzecieu/emscripten-docker/blob/master/docker/trzeci/emscripten-fastcomp/Dockerfile which supports builds:
  * fastcomp
  * upstream

Features:
* An image can be build with fastcomp and upstream version of Emscripten SDK
* It applies some extra size optimizations (that might be removed in sake of clarity / stability)
* It creates conventional `1000:1000` user `emscripten`
* It creates extra entrypoint that mitigates running as non-root user (Some context: https://trzeci.eu/fixing-permission-of-files-created-from-docker/)
* It has simple-stupid tests performed during building
This commit is contained in:
Piotr Paczkowski (trzeci.eu)
2019-10-11 20:21:47 +02:00
committed by Sam Clegg
parent 7f9af7bd1a
commit c56422590b
5 changed files with 437 additions and 0 deletions

27
docker/entrypoint Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
# In case when mapped user id by `docker run -u` is not created inside docker image
# The `$HOME` variable points to `/` - which prevents any tool to write to, as it requires root access
# In such case we set `$HOME` to `/tmp` as it should r/w for everyone
if [ "$HOME" = "/" ] ; then
export HOME=/tmp
fi
# In case of running as root, use `umask` to reduce problem of file permission on host
if [ "$(id -g)" = "0" ] && [ "$(id -u)" = "0" ] ;
then
umask 0000
fi
# Export this image specific Environment variables
# Those variables are important to use dedicated folder for all cache and predefined config file
export EM_CONFIG=/emsdk/.emscripten
export EM_CACHE=/emsdk/.data/cache
export EM_PORTS=/emsdk/.data/ports
# Activate Emscripten SDK
. ${EMSDK}/emsdk_set_env.sh
# Evaluate a command that's coming after `docker run` / `docker exec`
"$@"