-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
205 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM million12/nginx | ||
MAINTAINER Przemyslaw Ozgo [email protected] | ||
|
||
ENV GITBUCKET_VERSION=3.12 \ | ||
HOSTNAME=localhost \ | ||
CONTEXTPATH="" \ | ||
DATA_DIR=/data/gitbucket | ||
|
||
RUN \ | ||
rpm --rebuilddb && yum clean all && \ | ||
yum install -y java-1.8.0-openjdk wget && \ | ||
wget -L -O /opt/gitbucket.war https://github.com/gitbucket/gitbucket/releases/download/${GITBUCKET_VERSION}/gitbucket.war | ||
|
||
COPY container-files/ / | ||
|
||
EXPOSE 80 81 443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,116 @@ | ||
# docker-gitbucket | ||
GitBucket in Docker | ||
### GitBucker in Docker (Nginx/HTTP2) | ||
|
||
[![CircleCI Build Status](https://img.shields.io/circleci/project/million12/docker-gitbucket/master.svg)](https://circleci.com/gh/millio12/docker-bitbucket) | ||
[![GitHub Open Issues](https://img.shields.io/github/issues/million12/docker-gitbucket.svg)](https://github.com/million12/docker-gitbucket/issues) | ||
[![GitHub Stars](https://img.shields.io/github/stars/million12/docker-gitbucket.svg)](https://github.com/million12/docker-gitbucket) | ||
[![GitHub Forks](https://img.shields.io/github/forks/million12/docker-gitbucket.svg)](https://github.com/million12/docker-gitbucket) | ||
[![Stars on Docker Hub](https://img.shields.io/docker/stars/million12/gitbucket.svg)](https://hub.docker.com/r/million12/gitbucket) | ||
[![Pulls on Docker Hub](https://img.shields.io/docker/pulls/million12/gitbucket.svg)](https://hub.docker.com/r/million12/gitbucket) | ||
[![Docker Layers](https://badge.imagelayers.io/million12/gitbucket:latest.svg)](https://hub.docker.com/r/million12/gitbucket) | ||
|
||
[![Deploy to Docker Cloud](https://files.cloud.docker.com/images/deploy-to-dockercloud.svg)](https://cloud.docker.com/stack/deploy/?repo=https://github.com/million12/docker-gitbucket/tree/master) | ||
|
||
[Docker Image](https://registry.hub.docker.com/u/million12/gitbucket/) with GitBucket server using [million12/nginx](https://hub.docker.com/r/million12/nginx/) docker image as base. (HTTP2 and HAProxy SSL termination ready.) | ||
|
||
|
||
### Environmental Variable | ||
|
||
- `CONTEXTPATH` runtime variable `--prefix=` | ||
- `HOSTNAME` runtime variable `--host=` | ||
- `DATA_DIR` runtime variable `--gitbucket.home=` | ||
|
||
#### Nginx Features | ||
|
||
##### - HTTP/2 support | ||
Container is built with `http/2` support and by default it listens on port `443`. | ||
Make sure you open it on `docker run`. | ||
Port `81` is used by default for load balancing (`HAProxy`) ssl termination. | ||
|
||
##### - dummy SSL certificates | ||
The default *catch-all* vhost is configured to work on HTTPS as well. | ||
|
||
##### - error logging | ||
|
||
Nginx `error_log` is set to `stderr` and therefore Nginx log is available only via `docker logs [contaienr]`, together with supervisor logs. | ||
|
||
This is probably best approach if you'd like to source your logs from outside the container (e.g. via `docker logs` or CoreOS `journald`) and you don't want to worry about logging and log management inside your container. | ||
|
||
##### - graceful reload after config change | ||
|
||
Folders `/etc/nginx/` and `/data/conf/nginx/` are monitored for any config changes and, when they happen, Nginx is gracefully reloaded. | ||
|
||
##### - Nginx status page | ||
|
||
Nginx status page is configured under `/nginx_status` URL on the default vhost. Also see `STATUS_PAGE_ALLOWED_IP` env variable described below. | ||
Eample output: | ||
|
||
Active connections: 1 | ||
server accepts handled requests | ||
11475 11475 13566 | ||
Reading: 0 Writing: 1 Waiting: 0 | ||
|
||
### Usage | ||
|
||
docker run \ | ||
-d \ | ||
--name gitbucket \ | ||
-p 80:80 \ | ||
-p 443:443 \ | ||
million12/gitbucket | ||
|
||
Mount data to host os and edit some variables. | ||
|
||
docker run \ | ||
-d \ | ||
--name gitbucket \ | ||
-p 80:80 \ | ||
-p 443:443 \ | ||
-e HOSTNAME=myhostanme.com \ | ||
-e DATA_DIR=/my/custom/container/dir \ | ||
-v /my/host/dir:/my/custom/container/dir \ | ||
million12/gitbucket | ||
|
||
### Build | ||
|
||
docker build -t million12/gitbucket . | ||
|
||
### Access GitBucket web interface | ||
|
||
- HTTP: http://docker.ip | ||
- SSL/HTTP2: https://docker.ip | ||
|
||
**Default Login and Password is `root:root`** | ||
|
||
Docker troubleshooting | ||
====================== | ||
|
||
Use docker command to see if all required containers are up and running: | ||
``` | ||
$ docker ps | ||
``` | ||
|
||
Check logs of gitbucket server container: | ||
``` | ||
$ docker logs gitbucket | ||
``` | ||
|
||
Sometimes you might just want to review how things are deployed inside a running | ||
container, you can do this by executing a _bash shell_ through _docker's | ||
exec_ command: | ||
``` | ||
docker exec -ti gitbucket /bin/bash | ||
``` | ||
|
||
History of an image and size of layers: | ||
``` | ||
docker history --no-trunc=true million12/gitbucket | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}' | ||
``` | ||
|
||
## Author | ||
|
||
Author: Przemyslaw Ozgo (<[email protected]>) | ||
|
||
--- | ||
|
||
**Sponsored by [Prototype Brewery](http://prototypebrewery.io/)** - the new prototyping tool for building highly-interactive prototypes of your website or web app. Built on top of [Neos CMS](https://www.neos.io/) and [Zurb Foundation](http://foundation.zurb.com/) framework. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
machine: | ||
services: | ||
- docker | ||
|
||
dependencies: | ||
pre: | ||
- docker info && docker version | ||
|
||
test: | ||
pre: | ||
- docker build -t million12/gitbucket . | ||
|
||
override: | ||
# Start Gitbucket | ||
- docker run -d -p 80:80 -p 443:443 --name gitbucket million12/gitbucket | ||
- docker logs -f gitbucket | tee -a ${CIRCLE_ARTIFACTS}/gitbucket.log: | ||
background: true | ||
- while true; do if grep "Started ServerConnector" -a ${CIRCLE_ARTIFACTS}/gitbucket.log; then break; else sleep 1; fi done | ||
# Check connection on port 80 | ||
- curl -sSLi --head http://127.0.0.1/ | grep "HTTP/1.1 200 OK" | ||
# Check connection on port 443 | ||
- curl -sSLi --insecure --head https://127.0.0.1/ | grep "HTTP/1.1 200 OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
set -eu | ||
export TERM=xterm | ||
# Bash Colors | ||
green=`tput setaf 2` | ||
bold=`tput bold` | ||
reset=`tput sgr0` | ||
log() { | ||
if [[ "$@" ]]; then echo "${bold}${green}[LOG `date +'%T'`]${reset} $@"; | ||
else echo; fi | ||
} | ||
log "Creating Cache directory for nginx" | ||
mkdir -p /var/lib/nginx/ | ||
log "Starting GitBucket" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
server { | ||
listen 80 default_server; | ||
listen 81 default_server http2 proxy_protocol; ## Needed when behind HAProxy with SSL termination + HTTP/2 support | ||
listen 443 default_server ssl http2; | ||
|
||
ssl_certificate /etc/nginx/ssl/dummy.crt; | ||
ssl_certificate_key /etc/nginx/ssl/dummy.key; | ||
|
||
location / { | ||
proxy_pass http://localhost:8080; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_connect_timeout 150; | ||
proxy_send_timeout 100; | ||
proxy_read_timeout 100; | ||
proxy_buffers 4 32k; | ||
client_max_body_size 500m; # Big number is we can post big commits. | ||
client_body_buffer_size 128k; | ||
} | ||
location /assets/ { | ||
proxy_pass http://localhost:8080/assets/; | ||
proxy_cache cache; | ||
proxy_cache_key $host$uri$is_args$args; | ||
proxy_cache_valid 200 301 302 1d; | ||
expires 1d; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=cache:512m inactive=1d max_size=60g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[program:gitbucket] | ||
command = /usr/bin/java -jar /opt/gitbucket.war --host=%(ENV_HOSTNAME)s --prefix=%(ENV_CONTEXTPATH)s --gitbucket.home=%(ENV_DATA_DIR)s | ||
autorestart = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
gitbucket: | ||
image: million12/gitbucket | ||
ports: | ||
- "80:80" | ||
- "443:443" |