Implement a Dockerfile.

Apparently it's quite common nowadays for people to use docker to build
and run software in a contained way, so provide users with the facility
they need in order to do that.
This commit is contained in:
Dimitri Fontaine 2016-01-04 21:01:51 +01:00
parent 1bbbf96ba7
commit f8cb7601c5
3 changed files with 25 additions and 59 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
.git
.vagrant
build

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM debian:jessie
MAINTAINER Dimitri Fontaine <dim@tapoueh.org>
RUN apt-get update
RUN apt-get install -y wget curl make git bzip2 time libzip-dev libssl1.0.0 openssl
RUN apt-get install -y patch unzip libsqlite3-dev gawk freetds-dev sbcl
RUN mkdir -p /opt/src/pgloader
RUN git clone https://github.com/dimitri/pgloader /opt/src/pgloader
# we have build in the .dockerignore file, but we actually need it now
RUN mkdir -p /opt/src/pgloader/build/bin
RUN make PWD=/opt/src/pgloader -C /opt/src/pgloader
RUN cp /opt/src/pgloader/build/bin/pgloader /usr/local/bin

View File

@ -92,65 +92,13 @@ Now the `./build/bin/pgloader` that you get only uses 1GB.
## Building a docker image
We start with a `debian` image:
A `Dockerfile` is provided, to use it:
docker run -it debian bash
docker build -t pgloader:debian .
docker run --rm --name pgloader pgloader:debian bash -c "pgloader --version"
And then run the following steps:
The `build` step install build dependencies in a debian jessie container,
then `git clone` and build `pgloader` in `/opt/src/pgloader` and finally
copy the resulting binary image in `/usr/local/bin/pgloader` so that it's
easily available.
# apt-get update
# apt-get install -y wget curl make git bzip2 time libzip-dev openssl-dev
# apt-get install -y patch unzip libsqlite3-dev gawk freetds-dev
# useradd -m -s /bin/bash dim
# su - dim
Install a binary version on SBCL, which unfortunately has no support for
core compression, so only use it to build another SBCL version from sources
with proper options:
$ mkdir sbcl
$ cd sbcl
$ wget http://prdownloads.sourceforge.net/sbcl/sbcl-1.2.6-x86-64-linux-binary.tar.bz2
$ wget http://prdownloads.sourceforge.net/sbcl/sbcl-1.2.6-source.tar.bz2?download
$ mv sbcl-1.2.6-source.tar.bz2\?download sbcl-1.2.6-source.tar.bz2
$ tar xf sbcl-1.2.6-x86-64-linux-binary.tar.bz2
$ tar xf sbcl-1.2.6-source.tar.bz2
$ exit
Install SBCL as root
# cd /home/dim/sbcl/sbcl-1.2.6-x86-64-linux
# bash install.sh
Now back as the unprivileged user (dim) to compile SBCL from sources:
# su - dim
$ cd sbcl/sbcl-1.2.6
$ sh make.sh --with-sb-core-compression --with-sb-thread > build.out 2>&1
$ exit
And install the newly compiled SBCL as root:
# cd /home/dim/sbcl/sbcl-1.2.6
# sh install.sh
Now build pgloader from sources:
# su - dim
$ git clone https://github.com/dimitri/pgloader
$ cd pgloader
$ make
$ ./build/bin/pgloader --help
$ exit
Now install pgloader in `/usr/local/bin` to make it easy to use:
# cp /home/dim/pgloader/build/bin/pgloader /usr/local/bin
# pgloader --version
Commit the docker instance and push it, from the host:
$ docker login
$ docker ps -l
$ docker commit <id> dimitri/pgloader-3.1.cd52654
$ docker push dimitri/pgloader-3.1.cd52654