I wanted to build my favorite editor VILE for use on the Asustor NAS. But I quickly discovered that the GCC toolchain is not installed. I didn't want to go down the rabbit hole of installing gcc and whatever dependencies I needed. It could be done, but I don't think is good practice to be installing so many tools. For all I know, something installed might interfere with tools needed for normal operation or the upgrade process.
So knowing that Docker is a good solution for this sort of problem I started looking for minimal dev environments already available. In Docker Official Images, I found gcc image on dockerhub. The instructions are pretty simple and clear. But I needed to run multiple commands and I wanted to abstract it so I could easily modify for other apps. The result is simplified down to this flow:
- Download and unzip/untar source code to SRC_PATH (substituting SRC_PATH with wherever makes sense on your NAS). For me, this is the 'vile' editor source (from vile-9.8u) extracted to /volume1/home/me/ext/vile/vile-9.8u.
- Decide where to install on the NAS. A good choice might be a directory under /usr/local/AppCentral/opt. I'm using /usr/local/AppCentral/opt/vile and this path is passed in during my configuration step for the build.
- Outside your source code directory create the installer.sh script below.
- Customize your build and install steps.
- Customize a volume which binds an outer install path to the inner container path or remove it if you don't need it (in my case it is /usr/local/AppCentral/opt/vile; don't change the volume binding /usr/src/myapp).
- Customize the GCC version if it is important (I didn't modify this from the documentation for the gcc docker image; there are pro's and con's for forcing the version).
- Run: ./installer.sh SRC_PATH
- Enjoy your app (in my case supporting files installed under /usr/local/AppCentral/opt/vile with main binary /usr/local/AppCentral/opt/vile/bin/vile).
Code: Select all
#!/bin/sh
# pull gcc Docker container and run with given embedded command script
cd $1
CMD=__cmd.sh
cat > $CMD <<EOF
#!/bin/sh
# script you want to run inside container
# (e.g. steps to build & install app)
./configure --prefix=/usr/local/AppCentral/opt/vile
make
make install
EOF
chmod +x $CMD
docker run --rm \
-v /opt/vile:/opt/vile \
-v "$PWD":/usr/src/myapp \
-w /usr/src/myapp gcc:4.9 ./$CMD