aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--docker-compose.yaml24
-rw-r--r--gitlab/Dockerfile70
-rw-r--r--postgresql/Dockerfile17
-rwxr-xr-xpostgresql/docker-entrypoint.sh23
5 files changed, 145 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..5b231fa
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,11 @@
+IMAGES=gitlab-postgres gitlab
+.PHONY: $(IMAGES)
+
+all: $(IMAGES)
+
+gitlab-postgres:
+ docker build -t gitlab-postgres postgresql/
+
+gitlab:
+ docker build -t gitlab gitlab/
+
diff --git a/docker-compose.yaml b/docker-compose.yaml
new file mode 100644
index 0000000..febe6a3
--- /dev/null
+++ b/docker-compose.yaml
@@ -0,0 +1,24 @@
+version: '3'
+services:
+ postgresql:
+ container_name: gitlab-postgres
+ image: gitlab-postgres
+ volumes:
+ - pgdata:/var/lib/postgresql
+ - pgsocket:/run/postgresql
+ networks:
+ - gitlab-net
+
+ redis:
+ container_name: gitlab-redis
+ image: redis:alpine
+ networks:
+ - gitlab-net
+
+networks:
+ gitlab-net:
+
+volumes:
+ pgdata:
+ pgsocket:
+
diff --git a/gitlab/Dockerfile b/gitlab/Dockerfile
new file mode 100644
index 0000000..17f2ee2
--- /dev/null
+++ b/gitlab/Dockerfile
@@ -0,0 +1,70 @@
+FROM alpine:3.8
+
+ENV GITLAB_BRANCH 11-3-stable
+
+RUN apk add -U \
+ build-base \
+ zlib-dev \
+ yaml-dev \
+ libressl-dev \
+ gdbm-dev \
+ re2-dev \
+ readline-dev \
+ ncurses-dev \
+ libffi-dev \
+ curl-dev \
+ openssh-server \
+ libxml2-dev \
+ libxslt-dev \
+ icu-dev \
+ logrotate \
+ rsync \
+ py-docutils \
+ cmake \
+ ruby=~2.5 \
+ yarn \
+ nodejs \
+ sudo \
+ git \
+ go
+
+# create git user and config git
+RUN addgroup -S git \
+ && adduser -S -D -h /var/lib/git -s /bin/sh -G git -g git git \
+ && sudo -u git -H git config --global core.autocrlf input \
+ && sudo -u git -H git config --global gc.auto 0 \
+ && sudo -u git -H git config --global repack.writeBitmaps true \
+ && sudo -u git -H git config --global receive.advertisePushOptions true
+
+# clone gitlab repo
+RUN cd /var/lib/git \
+ && sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b $GITLAB_BRANCH gitlab
+
+# fix permissions
+RUN cd /var/lib/git/gitlab \
+ && chown -R git log/ tmp/ \
+ && chmod -R u+rwX,go-w log/ \
+ && chmod -R u+rwX tmp/ \
+ && chmod -R u+rwX tmp/pids/ \
+ && chmod -R u+rwX tmp/sockets/ \
+ \
+ && install -d -o git -g git -m0700 public/uploads \
+ && chmod -R u+rwX builds/ \
+ && chmod -R u+rwX shared/artifacts/ \
+ && chmod -R ug+rwX shared/pages/
+
+
+# the following files may need to be edited for our config
+RUN cd /var/lib/git/gitlab \
+ && install -o git -g git config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb \
+ && install -o git -g git config/gitlab.yml.example config/gitlab.yml \
+ && install -o git -g git -m0600 config/secrets.yml.example config/secrets.yml \
+ && install -o git -g git config/resque.yml.example config/resque.yml \
+ && install -o git -g git config/unicorn.rb.example config/unicorn.rb \
+ && install -o git -g git -m640 config/database.yml.postgresql config/database.yml
+
+
+
+
+
+
diff --git a/postgresql/Dockerfile b/postgresql/Dockerfile
new file mode 100644
index 0000000..50d8eca
--- /dev/null
+++ b/postgresql/Dockerfile
@@ -0,0 +1,17 @@
+FROM alpine:3.8
+
+ENV PGDATA /var/lib/postgresql/data
+ENV LANG en_US.utf8
+
+RUN apk add --no-cache postgresql postgresql-contrib su-exec \
+ && install -d -o postgres -g postgres -m 700 "$PGDATA" \
+ && install -d -o postgres -g postgres -m 700 /run/postgresql
+
+VOLUME /var/lib/postgresql/data
+
+COPY docker-entrypoint.sh /usr/local/bin/
+ENTRYPOINT ["docker-entrypoint.sh"]
+
+EXPOSE 5432
+CMD ["postgres"]
+
diff --git a/postgresql/docker-entrypoint.sh b/postgresql/docker-entrypoint.sh
new file mode 100755
index 0000000..c438de9
--- /dev/null
+++ b/postgresql/docker-entrypoint.sh
@@ -0,0 +1,23 @@
+#!/bin/sh -e
+
+_su(){
+ su-exec postgres "$@"
+}
+
+if ! [ -s "$PGDATA"/PG_VERSION ]; then
+ echo "Initializing database"
+ _su initdb --username=postgres
+
+ _su pg_ctl -D "$PGDATA" \
+ -o "-c listen_addresses=''" \
+ -w start
+
+ # create database for gitlab
+ _su psql -c "CREATE USER git CREATEDB;"
+ _su psql -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
+ _su psql -c "CREATE DATABASE gitlabhq_production OWNER git;"
+
+ _su pg_ctl -D "$PGDATA" -m fast -w stop
+fi
+
+_su "$@"