Merge pull request #1379 from tpires/develop

Update docker image.
This commit is contained in:
无闻 2015-07-25 00:24:39 +08:00
commit 52dd09fb76
17 changed files with 31 additions and 41 deletions

View file

@ -3,13 +3,13 @@ Docker
TOOLS ARE WRITTEN FOR TESTING AND TO SEE WHAT IT IS! TOOLS ARE WRITTEN FOR TESTING AND TO SEE WHAT IT IS!
For this to work you will need the nifty docker tool [fig]. For this to work you will need the nifty docker tool [docker-compose].
The most simple setup will look like this: The most simple setup will look like this:
```sh ```sh
./assemble_blocks.sh docker_gogs w_db option_db_mysql ./assemble_blocks.sh docker_gogs w_db option_db_mysql
fig up docker-compose up
``` ```
@ -22,21 +22,21 @@ How does it work
---------------- ----------------
`./assemble_blocks.sh` will look in `blocks` for subdirectories. `./assemble_blocks.sh` will look in `blocks` for subdirectories.
In the subdirectories there are three relevant files: `Dockerfile`, `config` and `fig`. In the subdirectories there are three relevant files: `Dockerfile`, `config` and `docker-compose`.
`Dockerfile` will be copied to `docker/` (also means last `Dockerfile` wins). `Dockerfile` will be copied to `docker/` (also means last `Dockerfile` wins).
The `config` file contains lines which will in the gogs docker container end up in `$GOGS_PATH/custom/config/app.ini` and by this gogs will be configured. The `config` file contains lines which will in the gogs docker container end up in `$GOGS_PATH/custom/config/app.ini` and by this gogs will be configured.
Here you can define things like the MySQL server for your database block. Here you can define things like the MySQL server for your database block.
The `fig` file will just be added to `fig.yml`, which is used by fig to manage your containers. The `docker-compose` file will just be added to `docker-compose.yml`, which is used by docker-compose to manage your containers.
This includes container linking! This includes container linking!
Just have a look at them and it will be clear how to write your own blocks. Just have a look at them and it will be clear how to write your own blocks.
Just some things Just some things
- all files (`Dockerfile`, `fig` and `config`) are optional - all files (`Dockerfile`, `docker-compose` and `config`) are optional
- the gogs block should always be the first block - the gogs block should always be the first block
Currently the blocks are designed that, the blocks that start with `docker` pull in the base docker image. Currently the blocks are designed that, the blocks that start with `docker` pull in the base docker image.
@ -57,14 +57,11 @@ Here is a more elaborated example
```sh ```sh
./assemble_blocks.sh docker_gogs w_db_cache_session option_db_postgresql option_cache_redis option_session_mysql ./assemble_blocks.sh docker_gogs w_db_cache_session option_db_postgresql option_cache_redis option_session_mysql
fig up docker-compose up
``` ```
This will set up four containters and link them proberly. One for each of This will set up four containters and link them proberly. One for each of
docker-compose
- gogs
- database (postgresql)
- cache (redis)
- session (mysql) - session (mysql)
WARNING: This will not work at the Moment! MySQL session is broken! WARNING: This will not work at the Moment! MySQL session is broken!
@ -73,7 +70,7 @@ WARNING: This will not work at the Moment! MySQL session is broken!
Remark Remark
------ ------
After you execute `assemble_blocks.sh` you should always trigger `fig build` to inculde the the new init script `init_gogs.sh` in the docker image. After you execute `assemble_blocks.sh` you should always trigger `docker-compose build` to inculde the the new init script `init_gogs.sh` in the docker image.
If you want to use another GoGS docker file, but keep everything else the same, you can create a block, e.g. `docker_gogs_custom`, with only a `Dockerfile` and call If you want to use another GoGS docker file, but keep everything else the same, you can create a block, e.g. `docker_gogs_custom`, with only a `Dockerfile` and call
@ -86,4 +83,4 @@ This will pull in the `Dockerfile` from `docker_gogs` instead of the one from `d
`Dockerfile`s for the `master` and `dev` branch are provided as `docker_gogs` and `docker_gogs_dev` `Dockerfile`s for the `master` and `dev` branch are provided as `docker_gogs` and `docker_gogs_dev`
[fig]:http://www.fig.sh/ [docker-compose]:https://docs.docker.com/compose/

View file

@ -10,8 +10,8 @@ gogs_config_file=conf.tmp
gogs_config=config gogs_config=config
gogs_init_file=$docker_dir/init_gogs.sh gogs_init_file=$docker_dir/init_gogs.sh
fig_file=fig.yml compose_file=docker-compose.yml
fig_config=fig compose_config=docker-compose
gogs_init_template=$template_dir/init_gogs.sh.tpl gogs_init_template=$template_dir/init_gogs.sh.tpl
@ -28,7 +28,7 @@ if [ "$#" == 0 ]; then
exit 0 exit 0
fi fi
for file in $gogs_config_file $fig_file; do for file in $gogs_config_file $compose_file; do
if [ -e $file ]; then if [ -e $file ]; then
echo "Deleting $file" echo "Deleting $file"
rm $file rm $file
@ -53,10 +53,10 @@ for dir in $@; do
echo "" >> $gogs_config_file echo "" >> $gogs_config_file
fi fi
if [ -e $current_dir/$fig_config ]; then if [ -e $current_dir/$compose_config ]; then
echo "Adding $current_dir/$fig_config to $fig_file" echo "Adding $current_dir/$compose_config to $compose_file"
cat $current_dir/fig >> $fig_file cat $current_dir/$compose_config >> $compose_file
echo "" >> $fig_file echo "" >> $compose_file
fi fi
done done

View file

@ -1,23 +1,20 @@
FROM ubuntu:14.04 FROM buildpack-deps:trusty-scm
# This part is taken from the official docker image -------------------- # This part is taken from the official docker image --------------------
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
build-essential ca-certificates curl \ build-essential --no-install-recommends
bzr git mercurial openssh-client\
--no-install-recommends
ENV GOLANG_VERSION 1.3 ENV GOLANG_VERSION 1.3
RUN curl -sSL http://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \ RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
| tar -v -C /usr/src -xz | tar -v -C /usr/src -xz
WORKDIR /usr/src/go
RUN cd src && ./make.bash --no-clean 2>&1 RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
ENV PATH /usr/src/go/bin:$PATH ENV PATH /usr/src/go/bin:$PATH
RUN mkdir -p /go/src RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
ENV GOPATH /go ENV GOPATH /go
ENV PATH /go/bin:$PATH ENV PATH /go/bin:$PATH
WORKDIR /go WORKDIR /go

View file

@ -1,24 +1,20 @@
FROM ubuntu:14.04 FROM buildpack-deps:trusty-scm
# This part is derived from the official docker image ------------------ # This part is taken from the official docker image --------------------
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ RUN apt-get update && apt-get install -y \
apt-get install -qy \ build-essential --no-install-recommends
build-essential ca-certificates curl \
bzr git mercurial openssh-client\
--no-install-recommends
ENV GOLANG_VERSION 1.3 ENV GOLANG_VERSION 1.3
RUN curl -sSL http://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \ RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
| tar -v -C /usr/src -xz | tar -v -C /usr/src -xz
WORKDIR /usr/src/go
RUN cd src && ./make.bash --no-clean 2>&1 RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
ENV PATH /usr/src/go/bin:$PATH ENV PATH /usr/src/go/bin:$PATH
RUN mkdir -p /go/src RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
ENV GOPATH /go ENV GOPATH /go
ENV PATH /go/bin:$PATH ENV PATH /go/bin:$PATH
WORKDIR /go WORKDIR /go