aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-08-17 17:15:03 +0800
committer无闻 <u@gogs.io>2015-08-17 17:15:03 +0800
commitf0067e8f78eaa9203cc6743116e7a2a3f82fe7eb (patch)
treed06c041490994fb4015c17737156c55cb877601c /docker
parent407385db7eae3ccdef235ac68273364bd704d0bd (diff)
parent9371fbe71a10f9449c805a1fd27968397d4f7cdb (diff)
Merge pull request #1494 from codeskyblue/develop
docker support ssh
Diffstat (limited to 'docker')
-rw-r--r--docker/README.md98
-rwxr-xr-xdocker/assemble_blocks.sh72
-rw-r--r--docker/blocks/docker_gogs/Dockerfile49
-rw-r--r--docker/blocks/docker_gogs_dev/Dockerfile49
-rw-r--r--docker/blocks/option_cache_memcache/config3
-rw-r--r--docker/blocks/option_cache_memcache/docker-compose2
-rw-r--r--docker/blocks/option_cache_redis/config3
-rw-r--r--docker/blocks/option_cache_redis/docker-compose2
-rw-r--r--docker/blocks/option_db_mysql/config6
-rw-r--r--docker/blocks/option_db_mysql/docker-compose7
-rw-r--r--docker/blocks/option_db_postgresql/config6
-rw-r--r--docker/blocks/option_db_postgresql/docker-compose6
-rw-r--r--docker/blocks/option_session_mysql/config3
-rw-r--r--docker/blocks/option_session_mysql/docker-compose7
-rw-r--r--docker/blocks/w_cache/docker-compose6
-rw-r--r--docker/blocks/w_cache_session/docker-compose7
-rw-r--r--docker/blocks/w_db/docker-compose6
-rw-r--r--docker/blocks/w_db_cache/docker-compose7
-rw-r--r--docker/blocks/w_db_cache_session/docker-compose8
-rw-r--r--docker/blocks/w_db_session/docker-compose7
-rw-r--r--docker/blocks/w_none/docker-compose4
-rw-r--r--docker/blocks/w_session/docker-compose6
-rw-r--r--docker/docker/.gitkeep0
-rwxr-xr-xdocker/start.sh47
-rw-r--r--docker/templates/init_gogs.sh.tpl12
25 files changed, 71 insertions, 352 deletions
diff --git a/docker/README.md b/docker/README.md
index 2ef37271..7b75e751 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -1,86 +1,36 @@
-Docker
-======
-
-TOOLS ARE WRITTEN FOR TESTING AND TO SEE WHAT IT IS!
-
-For this to work you will need the nifty docker tool [docker-compose].
-
-The most simple setup will look like this:
-
-```sh
-./assemble_blocks.sh docker_gogs w_db option_db_mysql
-docker-compose up
+# Docker for gogs
+## Usage
```
+docker pull gogits/gogs
-That's it. You have GoGS running in docker linked to a MySQL docker container.
-
-Now visit http://localhost:3000/ and give details for the admin account an you're up and running.
-
-
-How does it work
-----------------
-
-`./assemble_blocks.sh` will look in `blocks` for subdirectories.
-In the subdirectories there are three relevant files: `Dockerfile`, `config` and `docker-compose`.
-
-`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.
-Here you can define things like the MySQL server for your database block.
-
-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!
-
-Just have a look at them and it will be clear how to write your own blocks.
-
-Just some things
-
- - all files (`Dockerfile`, `docker-compose` and `config`) are optional
- - 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.
-Then one block starting with `w` defines, what containers should be linked to the gogs container.
-For every option in the `w` block you need to add an `option` container.
-
-Example:
-
-```sh
-./assemble_blocks.sh docker_gogs w_db_cache option_db_mysql option_cache_redis
+mkdir -p /var/gogs
+docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogits/gogs
```
+File will store in local path: `/var/gogs`
-More sophisticated Example
---------------------------
-
-Here is a more elaborated example
-
-```sh
-./assemble_blocks.sh docker_gogs w_db_cache_session option_db_postgresql option_cache_redis option_session_mysql
-docker-compose up
-```
-
-This will set up four containters and link them proberly. One for each of
-docker-compose
- - session (mysql)
+Directory `/var/gogs` keeps git repos and gogs data
-WARNING: This will not work at the Moment! MySQL session is broken!
+ /var/gogs
+ |-- git
+ | `-- gogs-repositories
+ |-- ssh
+ | `-- # ssh pub-pri keys for gogs
+ `---- gogs
+ |-- conf
+ |-- data
+ |-- log
+ `-- templates
+## SSH Support
-Remark
-------
+In order to support ssh, You need to change `HTTP_PORT` and `SSH_PORT` in `/var/gogs/gogs/conf/app.ini`
-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
-
-```sh
-./assemble_blocks.sh docker_gogs_custom w_db option_database_mysql
+```
+[server]
+HTTP_PORT = 3000
+SSH_PORT = 10022
```
-This will pull in the `Dockerfile` from `docker_gogs` instead of the one from `docker_gogs`.
-
-`Dockerfile`s for the `master` and `dev` branch are provided as `docker_gogs` and `docker_gogs_dev`
-
-
-[docker-compose]:https://docs.docker.com/compose/
+setting description can be found in <http://gogs.io/docs/advanced/configuration_cheat_sheet.html>
diff --git a/docker/assemble_blocks.sh b/docker/assemble_blocks.sh
deleted file mode 100755
index 3109a6a0..00000000
--- a/docker/assemble_blocks.sh
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-
-blocks_dir=blocks
-docker_dir=docker
-template_dir=templates
-
-docker_file=Dockerfile
-
-gogs_config_file=conf.tmp
-gogs_config=config
-gogs_init_file=$docker_dir/init_gogs.sh
-
-compose_file=docker-compose.yml
-compose_config=docker-compose
-
-gogs_init_template=$template_dir/init_gogs.sh.tpl
-
-if [ "$#" == 0 ]; then
- blocks=`ls $blocks_dir`
- if [ -z "$blocks" ]; then
- echo "No Blocks available in $blocks_dir"
- else
- echo "Available Blocks:"
- for block in $blocks; do
- echo " $block"
- done
- fi
- exit 0
-fi
-
-for file in $gogs_config_file $compose_file; do
- if [ -e $file ]; then
- echo "Deleting $file"
- rm $file
- fi
-done
-
-for dir in $@; do
- current_dir=$blocks_dir/$dir
- if [ ! -d "$current_dir" ]; then
- echo "$current_dir is not a directory"
- exit 1
- fi
-
- if [ -e $current_dir/$docker_file ]; then
- echo "Copying $current_dir/$docker_file to $docker_dir/$docker_file"
- cp $current_dir/$docker_file $docker_dir/$docker_file
- fi
-
- if [ -e $current_dir/$gogs_config ]; then
- echo "Adding $current_dir/$gogs_config to $gogs_config_file"
- cat $current_dir/$gogs_config >> $gogs_config_file
- echo "" >> $gogs_config_file
- fi
-
- if [ -e $current_dir/$compose_config ]; then
- echo "Adding $current_dir/$compose_config to $compose_file"
- cat $current_dir/$compose_config >> $compose_file
- echo "" >> $compose_file
- fi
-done
-
-echo "Creating $gogs_init_file"
-sed "/{{ CONFIG }}/{
-r $gogs_config_file
-d
-}" $gogs_init_template > $gogs_init_file
-
-if [ -e $gogs_config_file ]; then
- echo "Removing temporary GoGS config"
- rm $gogs_config_file
-fi
diff --git a/docker/blocks/docker_gogs/Dockerfile b/docker/blocks/docker_gogs/Dockerfile
deleted file mode 100644
index 1b58fbcf..00000000
--- a/docker/blocks/docker_gogs/Dockerfile
+++ /dev/null
@@ -1,49 +0,0 @@
-FROM buildpack-deps:trusty-scm
-
-# This part is taken from the official docker image --------------------
-
-RUN apt-get update && apt-get install -y \
- build-essential --no-install-recommends
-
-ENV GOLANG_VERSION 1.3
-
-RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
- | tar -v -C /usr/src -xz
-
-RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
-
-ENV PATH /usr/src/go/bin:$PATH
-
-RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
-ENV GOPATH /go
-ENV PATH /go/bin:$PATH
-WORKDIR /go
-
-# ----------------------------------------------------------------------
-
-
-RUN useradd -m git
-
-ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs
-ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf
-ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini
-
-RUN go get -u -d github.com/gogits/gogs
-# WORKDIR $GOGS_PATH
-WORKDIR /go/src/github.com/gogits/gogs
-RUN go build github.com/gogits/gogs
-RUN chown -R git $GOGS_PATH
-
-ADD init_gogs.sh /tmp/
-RUN chown git /tmp/init_gogs.sh
-RUN chmod +x /tmp/init_gogs.sh
-
-USER git
-ENV HOME /home/git
-ENV USER git
-ENV PATH $GOGS_PATH:$PATH
-
-RUN git config --global user.name "GoGS" && git config --global user.email "gogitservice@gmail.com"
-
-ENTRYPOINT ["/tmp/init_gogs.sh"]
-CMD ["gogs", "web"]
diff --git a/docker/blocks/docker_gogs_dev/Dockerfile b/docker/blocks/docker_gogs_dev/Dockerfile
deleted file mode 100644
index a51d165e..00000000
--- a/docker/blocks/docker_gogs_dev/Dockerfile
+++ /dev/null
@@ -1,49 +0,0 @@
-FROM buildpack-deps:trusty-scm
-
-# This part is taken from the official docker image --------------------
-
-RUN apt-get update && apt-get install -y \
- build-essential --no-install-recommends
-
-ENV GOLANG_VERSION 1.3
-
-RUN curl -sSL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz \
- | tar -v -C /usr/src -xz
-
-RUN cd /usr/src/go/src && ./make.bash --no-clean 2>&1
-
-ENV PATH /usr/src/go/bin:$PATH
-
-RUN mkdir -p /go/src /go/bin && chmod -R 777 /go
-ENV GOPATH /go
-ENV PATH /go/bin:$PATH
-WORKDIR /go
-
-# ----------------------------------------------------------------------
-
-
-RUN useradd -m git
-
-ENV GOGS_PATH $GOPATH/src/github.com/gogits/gogs
-ENV GOGS_CUSTOM_CONF_PATH $GOGS_PATH/custom/conf
-ENV GOGS_CUSTOM_CONF $GOGS_CUSTOM_CONF_PATH/app.ini
-
-RUN git clone -b dev https://github.com/gogits/gogs.git $GOGS_PATH
-# WORKDIR $GOGS_PATH
-WORKDIR /go/src/github.com/gogits/gogs
-RUN go get -d && go build
-RUN chown -R git $GOGS_PATH
-
-ADD init_gogs.sh /tmp/
-RUN chown git /tmp/init_gogs.sh
-RUN chmod +x /tmp/init_gogs.sh
-
-USER git
-ENV HOME /home/git
-ENV USER git
-ENV PATH $GOGS_PATH:$PATH
-
-RUN git config --global user.name "GoGS" && git config --global user.email "gogitservice@gmail.com"
-
-ENTRYPOINT ["/tmp/init_gogs.sh"]
-CMD ["gogs", "web"]
diff --git a/docker/blocks/option_cache_memcache/config b/docker/blocks/option_cache_memcache/config
deleted file mode 100644
index daca6f3e..00000000
--- a/docker/blocks/option_cache_memcache/config
+++ /dev/null
@@ -1,3 +0,0 @@
-[cache]
-DB_TYPE = memcache
-HOST = HOST = ${CACHE_1_PORT_11211_TCP_ADDR}:${CACHE_1_PORT_11211_TCP_PORT}
diff --git a/docker/blocks/option_cache_memcache/docker-compose b/docker/blocks/option_cache_memcache/docker-compose
deleted file mode 100644
index 80d0215c..00000000
--- a/docker/blocks/option_cache_memcache/docker-compose
+++ /dev/null
@@ -1,2 +0,0 @@
-cache:
- image: sylvainlasnier/memcached:latest
diff --git a/docker/blocks/option_cache_redis/config b/docker/blocks/option_cache_redis/config
deleted file mode 100644
index 648f4f38..00000000
--- a/docker/blocks/option_cache_redis/config
+++ /dev/null
@@ -1,3 +0,0 @@
-[cache]
-DB_TYPE = redis
-HOST = ${CACHE_1_PORT_6379_TCP_ADDR}:${CACHE_1_PORT_6379_TCP_PORT}
diff --git a/docker/blocks/option_cache_redis/docker-compose b/docker/blocks/option_cache_redis/docker-compose
deleted file mode 100644
index 0e74bc4a..00000000
--- a/docker/blocks/option_cache_redis/docker-compose
+++ /dev/null
@@ -1,2 +0,0 @@
-cache:
- image: redis:latest
diff --git a/docker/blocks/option_db_mysql/config b/docker/blocks/option_db_mysql/config
deleted file mode 100644
index 53f8949d..00000000
--- a/docker/blocks/option_db_mysql/config
+++ /dev/null
@@ -1,6 +0,0 @@
-[database]
-DB_TYPE = mysql
-HOST = ${DB_1_PORT_3306_TCP_ADDR}:${DB_1_PORT_3306_TCP_PORT}
-NAME = ${DB_1_ENV_MYSQL_DATABASE}
-USER = ${DB_1_ENV_MYSQL_USER}
-PASSWD = ${DB_1_ENV_MYSQL_PASSWORD}
diff --git a/docker/blocks/option_db_mysql/docker-compose b/docker/blocks/option_db_mysql/docker-compose
deleted file mode 100644
index a005a059..00000000
--- a/docker/blocks/option_db_mysql/docker-compose
+++ /dev/null
@@ -1,7 +0,0 @@
-db:
- image: mysql:latest
- environment:
- MYSQL_ROOT_PASSWORD: rootpass
- MYSQL_DATABASE: gogs
- MYSQL_USER: gogs
- MYSQL_PASSWORD: password
diff --git a/docker/blocks/option_db_postgresql/config b/docker/blocks/option_db_postgresql/config
deleted file mode 100644
index e5946b06..00000000
--- a/docker/blocks/option_db_postgresql/config
+++ /dev/null
@@ -1,6 +0,0 @@
-[database]
-DB_TYPE = postgres
-HOST = ${DB_1_PORT_5432_TCP_ADDR}:${DB_1_PORT_5432_TCP_PORT}
-NAME = ${DB_1_ENV_POSTGRESQL_DB}
-USER = ${DB_1_ENV_POSTGRESQL_USER}
-PASSWD = ${DB_1_ENV_POSTGRESQL_PASS}
diff --git a/docker/blocks/option_db_postgresql/docker-compose b/docker/blocks/option_db_postgresql/docker-compose
deleted file mode 100644
index c839e904..00000000
--- a/docker/blocks/option_db_postgresql/docker-compose
+++ /dev/null
@@ -1,6 +0,0 @@
-db:
- image: wyaeld/postgres:9.3
- environment:
- POSTGRESQL_DB: gogs
- POSTGRESQL_USER: gogs
- POSTGRESQL_PASS: password
diff --git a/docker/blocks/option_session_mysql/config b/docker/blocks/option_session_mysql/config
deleted file mode 100644
index b8bc2cc7..00000000
--- a/docker/blocks/option_session_mysql/config
+++ /dev/null
@@ -1,3 +0,0 @@
-[session]
-PROVIDER = mysql
-PROVIDER_CONFIG = ${SESSION_1_ENV_MYSQL_USER}:${SESSION_1_ENV_MYSQL_PASSWORD}@SESSION_1_PORT_3306_TCP_PROTO(${SESSION_1_PORT_3306_TCP_ADDR}:${SESSION_1_PORT_3306_TCP_PORT})/${SESSION_1_ENV_MYSQL_DATABASE}
diff --git a/docker/blocks/option_session_mysql/docker-compose b/docker/blocks/option_session_mysql/docker-compose
deleted file mode 100644
index 0e2dbf19..00000000
--- a/docker/blocks/option_session_mysql/docker-compose
+++ /dev/null
@@ -1,7 +0,0 @@
-session:
- image: mysql:latest
- environment:
- MYSQL_ROOT_PASSWORD: rootpass
- MYSQL_DATABASE: gogs_session
- MYSQL_USER: gogs
- MYSQL_PASSWORD: password
diff --git a/docker/blocks/w_cache/docker-compose b/docker/blocks/w_cache/docker-compose
deleted file mode 100644
index fd66c357..00000000
--- a/docker/blocks/w_cache/docker-compose
+++ /dev/null
@@ -1,6 +0,0 @@
-gogs:
- build: docker
- links:
- - cache
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_cache_session/docker-compose b/docker/blocks/w_cache_session/docker-compose
deleted file mode 100644
index 0f901140..00000000
--- a/docker/blocks/w_cache_session/docker-compose
+++ /dev/null
@@ -1,7 +0,0 @@
-gogs:
- build: docker
- links:
- - cache
- - session
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_db/docker-compose b/docker/blocks/w_db/docker-compose
deleted file mode 100644
index a7e9c1b6..00000000
--- a/docker/blocks/w_db/docker-compose
+++ /dev/null
@@ -1,6 +0,0 @@
-gogs:
- build: docker
- links:
- - db
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_db_cache/docker-compose b/docker/blocks/w_db_cache/docker-compose
deleted file mode 100644
index 42402e40..00000000
--- a/docker/blocks/w_db_cache/docker-compose
+++ /dev/null
@@ -1,7 +0,0 @@
-gogs:
- build: docker
- links:
- - db
- - cache
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_db_cache_session/docker-compose b/docker/blocks/w_db_cache_session/docker-compose
deleted file mode 100644
index 42444405..00000000
--- a/docker/blocks/w_db_cache_session/docker-compose
+++ /dev/null
@@ -1,8 +0,0 @@
-gogs:
- build: docker
- links:
- - db
- - cache
- - session
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_db_session/docker-compose b/docker/blocks/w_db_session/docker-compose
deleted file mode 100644
index 3703c6ba..00000000
--- a/docker/blocks/w_db_session/docker-compose
+++ /dev/null
@@ -1,7 +0,0 @@
-gogs:
- build: docker
- links:
- - db
- - session
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_none/docker-compose b/docker/blocks/w_none/docker-compose
deleted file mode 100644
index c0fed209..00000000
--- a/docker/blocks/w_none/docker-compose
+++ /dev/null
@@ -1,4 +0,0 @@
-gogs:
- build: docker
- ports:
- - "3000:3000"
diff --git a/docker/blocks/w_session/docker-compose b/docker/blocks/w_session/docker-compose
deleted file mode 100644
index 7dda0dde..00000000
--- a/docker/blocks/w_session/docker-compose
+++ /dev/null
@@ -1,6 +0,0 @@
-gogs:
- build: docker
- links:
- - session
- ports:
- - "3000:3000"
diff --git a/docker/docker/.gitkeep b/docker/docker/.gitkeep
deleted file mode 100644
index e69de29b..00000000
--- a/docker/docker/.gitkeep
+++ /dev/null
diff --git a/docker/start.sh b/docker/start.sh
new file mode 100755
index 00000000..47a835ad
--- /dev/null
+++ b/docker/start.sh
@@ -0,0 +1,47 @@
+#!/bin/bash -
+#
+
+if ! test -d /data/gogs
+then
+ mkdir -p /var/run/sshd
+ mkdir -p /data/gogs/data /data/gogs/conf /data/gogs/log /data/git
+fi
+
+if ! test -d /data/ssh
+then
+ mkdir /data/ssh
+ ssh-keygen -q -f /data/ssh/ssh_host_key -N '' -t rsa1
+ ssh-keygen -q -f /data/ssh/ssh_host_rsa_key -N '' -t rsa
+ ssh-keygen -q -f /data/ssh/ssh_host_dsa_key -N '' -t dsa
+ ssh-keygen -q -f /data/ssh/ssh_host_ecdsa_key -N '' -t ecdsa
+ ssh-keygen -q -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519
+ chown -R root:root /data/ssh/*
+ chmod 600 /data/ssh/*
+fi
+
+service ssh start
+
+# sync templates
+test -d /data/gogs/templates || cp -ar ./templates /data/gogs/
+rsync -rtv /data/gogs/templates/ ./templates/
+
+ln -sf /data/gogs/log ./log
+ln -sf /data/gogs/data ./data
+ln -sf /data/git /home/git
+
+
+if ! test -d ~git/.ssh
+then
+ mkdir ~git/.ssh
+ chmod 700 ~git/.ssh
+fi
+
+if ! test -f ~git/.ssh/environment
+then
+ echo "GOGS_CUSTOM=/data/gogs" > ~git/.ssh/environment
+ chown git:git ~git/.ssh/environment
+ chown 600 ~git/.ssh/environment
+fi
+
+chown -R git:git /data .
+exec su git -c "./gogs web"
diff --git a/docker/templates/init_gogs.sh.tpl b/docker/templates/init_gogs.sh.tpl
deleted file mode 100644
index ada11f95..00000000
--- a/docker/templates/init_gogs.sh.tpl
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-if [ ! -d "$GOGS_CUSTOM_CONF_PATH" ]; then
- mkdir -p $GOGS_CUSTOM_CONF_PATH
-
-echo "
-{{ CONFIG }}
-" >> $GOGS_CUSTOM_CONF
-
-fi
-
-exec "$@"