diff options
| author | Mhd Sulhan <ms@kilabit.info> | 2015-09-15 00:56:13 +0700 |
|---|---|---|
| committer | Mhd Sulhan <ms@kilabit.info> | 2015-09-15 00:56:13 +0700 |
| commit | e9e4a1a7f3618e2fc636dcc3b9e1c6d1f5788cdb (patch) | |
| tree | c5e7df80e1c3f5c5cd627621e20d5b0bb03d4897 | |
| parent | 45f80367326abbdac2b9575620e96024b9bde57d (diff) | |
| download | arch-docker-e9e4a1a7f3618e2fc636dcc3b9e1c6d1f5788cdb.tar.xz | |
Various fixes and updates.
## news
- init.sh: script to run if no command given.
- run.sh: sample script to run the image.
## Dockerfile.local,Dockerfile.online
- Set volume.
- Reorder command to optimize using image caches.
- Use init.sh as start command.
## bootstrap.sh
Always sync when running pacman. This is to prevent error 404 when
downloading package because the file has been removed on server.
## build.sh
Merge copy commands into single command.
| -rw-r--r-- | arch-nodejs/Dockerfile.local | 17 | ||||
| -rw-r--r-- | arch-nodejs/Dockerfile.online | 11 | ||||
| -rwxr-xr-x | arch-nodejs/bootstrap.sh | 2 | ||||
| -rwxr-xr-x | arch-nodejs/build.sh | 42 | ||||
| -rwxr-xr-x | arch-nodejs/init.sh | 13 | ||||
| -rwxr-xr-x | arch-nodejs/run.sh | 18 |
6 files changed, 79 insertions, 24 deletions
diff --git a/arch-nodejs/Dockerfile.local b/arch-nodejs/Dockerfile.local index 7c8368e..7197320 100644 --- a/arch-nodejs/Dockerfile.local +++ b/arch-nodejs/Dockerfile.local @@ -1,13 +1,22 @@ +## +## Image for Arch Linux system with nodejs and npm. +## +## Run this image with volume mounted at /srv/www, +## +## docker run -v ${PWD}/src:/srv/www -it sulhan/arch-nodejs +## FROM sulhan/arch-base:latest MAINTAINER Sulhan <ms@kilabit.info> -COPY *.db /var/lib/pacman/sync/ -COPY *.xz /var/cache/pacman/pkg/ - +VOLUME /srv/www EXPOSE 80 +COPY init.sh / COPY bootstrap.sh / +COPY *.db /var/lib/pacman/sync/ +COPY *.xz /var/cache/pacman/pkg/ + RUN exec /bootstrap.sh -CMD ["/bin/bash"] +CMD ["/init.sh"] diff --git a/arch-nodejs/Dockerfile.online b/arch-nodejs/Dockerfile.online index 50921d4..d8dbf37 100644 --- a/arch-nodejs/Dockerfile.online +++ b/arch-nodejs/Dockerfile.online @@ -1,10 +1,19 @@ +## +## Image for Arch Linux system with nodejs and npm. +## +## Run this image with volume mounted at /srv/www, +## +## docker run -v ${PWD}/src:/srv/www -it sulhan/arch-nodejs +## FROM sulhan/arch-base:latest MAINTAINER Sulhan <ms@kilabit.info> +VOLUME /srv/www EXPOSE 80 +COPY init.sh / COPY bootstrap.sh / RUN exec /bootstrap.sh -CMD ["/bin/bash"] +CMD ["/init.sh"] diff --git a/arch-nodejs/bootstrap.sh b/arch-nodejs/bootstrap.sh index 7531d8a..d6bcd92 100755 --- a/arch-nodejs/bootstrap.sh +++ b/arch-nodejs/bootstrap.sh @@ -31,7 +31,7 @@ clean_common() { } do_install() { - pacman -S --noconfirm $PACKAGES + pacman -Sy --noconfirm $PACKAGES return $? } diff --git a/arch-nodejs/build.sh b/arch-nodejs/build.sh index c671f36..0f26682 100755 --- a/arch-nodejs/build.sh +++ b/arch-nodejs/build.sh @@ -54,31 +54,37 @@ sudo pacman -Syw --noconfirm --needed $PACKAGES cp /var/lib/pacman/sync/*.db ./ ## git. -cp /var/cache/pacman/pkg/db-5.* ./ -cp /var/cache/pacman/pkg/perl-5.* ./ -cp /var/cache/pacman/pkg/git-2.* ./ +cp /var/cache/pacman/pkg/db-5.* \ + /var/cache/pacman/pkg/perl-5.* \ + /var/cache/pacman/pkg/perl-error-* \ + /var/cache/pacman/pkg/git-2.* \ + ./ ## gcc. -cp /var/cache/pacman/pkg/libmpc-1.* ./ -cp /var/cache/pacman/pkg/gcc-5.* ./ +cp /var/cache/pacman/pkg/libmpc-1.* \ + /var/cache/pacman/pkg/gcc-5.* \ + ./ -## python. -cp /var/cache/pacman/pkg/sqlite-3* ./ -cp /var/cache/pacman/pkg/python2-2.* ./ +## python 2. +cp /var/cache/pacman/pkg/sqlite-3* \ + /var/cache/pacman/pkg/python2-2.* \ + ./ ## make. -cp /var/cache/pacman/pkg/tar-1.* ./ -cp /var/cache/pacman/pkg/libtool-2.* ./ -cp /var/cache/pacman/pkg/libunistring* ./ -cp /var/cache/pacman/pkg/libatomic_ops* ./ -cp /var/cache/pacman/pkg/gc-7.* ./ -cp /var/cache/pacman/pkg/guile-2.* ./ -cp /var/cache/pacman/pkg/make-4.* ./ +cp /var/cache/pacman/pkg/tar-1.* \ + /var/cache/pacman/pkg/libtool-2.* \ + /var/cache/pacman/pkg/libunistring* \ + /var/cache/pacman/pkg/libatomic_ops* \ + /var/cache/pacman/pkg/gc-7.* \ + /var/cache/pacman/pkg/guile-2.* \ + /var/cache/pacman/pkg/make-4.* \ + ./ ## nodejs -cp /var/cache/pacman/pkg/icu-55.* ./ -cp /var/cache/pacman/pkg/nodejs-0.12.* ./ -cp /var/cache/pacman/pkg/npm-2.14.* ./ +cp /var/cache/pacman/pkg/icu-55.* \ + /var/cache/pacman/pkg/nodejs-0.12.* \ + /var/cache/pacman/pkg/npm-2.14.* \ + ./ rm -f Dockerfile ln -s Dockerfile.local Dockerfile diff --git a/arch-nodejs/init.sh b/arch-nodejs/init.sh new file mode 100755 index 0000000..24c520f --- /dev/null +++ b/arch-nodejs/init.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +export WORKDIR=${WORKDIR:-"/srv/www"} +export COMMANDS=${COMMANDS:-"npm start"} +export NODE_ENV=${NODE_ENV:-"development"} + +cd $WORKDIR + +if [ ! -d $WORKDIR/node_modules ]; then + npm install +fi + +eval $COMMANDS diff --git a/arch-nodejs/run.sh b/arch-nodejs/run.sh new file mode 100755 index 0000000..e8267bc --- /dev/null +++ b/arch-nodejs/run.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +SRC=${SRC:-"$PWD/src"} +LINK=$([ "$LINK"x == "x" ] && echo "" || echo "--link $LINK") + +export WORKDIR=${WORKDIR:-"/srv/www"} +export COMMANDS=${COMMANDS:-"npm start"} +export NODE_ENV=${NODE_ENV:-"development"} + +## run docker using host data directory as postgresql dictionary files. +docker run -p 80:80 --rm --name nodejs \ + $LINK \ + -v $SRC:/srv/www \ + -e "WORKDIR=$WORKDIR" \ + -e "COMMANDS=$COMMANDS" \ + -e "NODE_ENV=$NODE_ENV" \ + -it sulhan/arch-nodejs \ + $@ |
