diff --git a/Dockerfile b/Dockerfile index af4d9a4..6e03405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM centos:7 MAINTAINER Erik Jacobs -ENV GOGS_VERSION="0.9.113" +ARG GOGS_VERSION="0.9.113" LABEL name="Gogs - Go Git Service" \ vendor="Gogs" \ @@ -11,17 +11,18 @@ LABEL name="Gogs - Go Git Service" \ summary="The goal of this project is to make the easiest, fastest, and most painless way of setting up a self-hosted Git service." \ io.openshift.expose-services="3000,gogs" \ io.openshift.tags="gogs" \ - build-date="2017-01-05" \ - version="0.9.113" \ + build-date="2017-04-02" \ + version="${GOGS_VERSION}" \ release="1" ENV HOME=/var/lib/gogs COPY ./root / -RUN rpm --import https://rpm.packager.io/key && \ +RUN curl -L -o /etc/yum.repos.d/gogs.repo https://dl.packager.io/srv/pkgr/gogs/pkgr/installer/el/7.repo && \ + rpm --import https://rpm.packager.io/key && \ yum -y install epel-release && \ - yum -y --setopt=tsflags=nodocs install gogs nss_wrapper gettext && \ + yum -y --setopt=tsflags=nodocs install gogs-${GOGS_VERSION} nss_wrapper gettext && \ yum -y clean all && \ mkdir -p /var/lib/gogs diff --git a/README.md b/README.md index a44a957..9380510 100644 --- a/README.md +++ b/README.md @@ -9,29 +9,33 @@ requirements. This repository contains: * OpenShift templates for deploying the image * Usage instructions -## Prerequisites -* An account in an OpenShift 3.2+ environment and a project - -* Gogs requires a database to store its information. Provisioning a database is - out-of-scope for this repository. If you wish to run the database on - OpenShift, it is suggested that you deploy PostgreSQL using persistent - storage. More information on the OpenShift PostgreSQL deployment is here: +## Deployment +There are two templates available: _persistent_ and _non-persistent_. The pesistent one requires two `PersistentVolume` available with default size required of 1Gi (the volume size can be specified with the template variables: `GOGS_VOLUME_CAPACITY` and `DB_VOLUME_CAPACITY`). - https://docs.openshift.org/latest/using_images/db_images/postgresql.html +* gogs-data +* gogs-postgres-data -## Deployment -Gogs can be easily deployed using the included templates in `openshift` folder. -If your have persistent volumes available in your cluster: +Both templates will provision two linked pods: one for GOGS and other for Postgresql DB. If your have persistent volumes available in your cluster: ``` -oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-persistent-template.yaml --param=HOSTNAME=gogs-demo.yourdomain.com +oc new-app -f http://bit.ly/openshift-gogs-persistent-template --param=HOSTNAME=gogs-demo.yourdomain.com ``` + Otherwise: ``` -oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-template.yaml --param=HOSTNAME=gogs-demo.yourdomain.com +oc new-app -f http://bit.ly/openshift-gogs-template --param=HOSTNAME=gogs-demo.yourdomain.com ``` Note that hostname is required during Gogs installation in order to configure repository urls correctly. -## ToDos -* git via ssh support +## Gogs Versions +You can deploy any of the available Gogs versions on [openshiftdemos/gogs](https://hub.docker.com/r/openshiftdemos/gogs/tags/) on Docker Hub using the ```GOGS_VERSION``` template parameter: +``` +oc new-app -f http://bit.ly/openshift-gogs-template --param=HOSTNAME=gogs-demo.yourdomain.com --param=GOGS_VERSION=0.11.4 +``` + +# Gogs Admin User +After Gogs deployment, the first registered user will be admin. The default administrator can log into Admin > Users and authorize another user. A user will also be an > administrator if they register in the install page. Read more on [Gogs FAQ](https://gogs.io/docs/intro/faqs#how-can-i-become-an-administrator%3F) + + + diff --git a/openshift/gogs-persistent-template.yaml b/openshift/gogs-persistent-template.yaml index 944e14b..dc1b305 100644 --- a/openshift/gogs-persistent-template.yaml +++ b/openshift/gogs-persistent-template.yaml @@ -19,6 +19,8 @@ objects: annotations: description: Exposes the database server name: ${APPLICATION_NAME}-postgresql + labels: + app: ${APPLICATION_NAME} spec: ports: - name: postgresql @@ -32,6 +34,8 @@ objects: annotations: description: Defines how to deploy the database name: ${APPLICATION_NAME}-postgresql + labels: + app: ${APPLICATION_NAME} spec: replicas: 1 selector: @@ -65,6 +69,8 @@ objects: tcpSocket: port: 5432 timeoutSeconds: 1 + failureThreshold: 10 + periodSeconds: 20 name: postgresql ports: - containerPort: 5432 @@ -75,8 +81,9 @@ objects: - -i - -c - psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1' - initialDelaySeconds: 5 + initialDelaySeconds: 30 timeoutSeconds: 1 + failureThreshold: 10 resources: limits: memory: 512Mi @@ -94,7 +101,7 @@ objects: - postgresql from: kind: ImageStreamTag - name: postgresql:9.4 + name: postgresql:${DATABASE_VERSION} namespace: openshift type: ImageChange - type: ConfigChange @@ -180,21 +187,21 @@ objects: path: / port: 3000 scheme: HTTP - initialDelaySeconds: 3 + initialDelaySeconds: 40 timeoutSeconds: 1 periodSeconds: 20 successThreshold: 1 - failureThreshold: 3 + failureThreshold: 10 livenessProbe: httpGet: path: / port: 3000 scheme: HTTP - initialDelaySeconds: 3 + initialDelaySeconds: 40 timeoutSeconds: 1 periodSeconds: 10 successThreshold: 1 - failureThreshold: 3 + failureThreshold: 10 dnsPolicy: ClusterFirst restartPolicy: Always securityContext: {} @@ -218,7 +225,7 @@ objects: - ${APPLICATION_NAME} from: kind: ImageStreamTag - name: ${APPLICATION_NAME}:latest + name: ${APPLICATION_NAME}:${GOGS_VERSION} type: ImageChange - kind: ImageStream apiVersion: v1 @@ -237,19 +244,12 @@ objects: description: The Gogs git server docker image tags: gogs,go,golang version: "${GOGS_VERSION}" - - annotations: - description: The Gogs git server docker image - tags: gogs,go,golang - version: "latest" - from: - kind: ImageStreamTag - name: "${GOGS_VERSION}" - importPolicy: {} - name: "latest" - kind: PersistentVolumeClaim apiVersion: v1 metadata: name: gogs-data + labels: + app: ${APPLICATION_NAME} spec: accessModes: - ReadWriteOnce @@ -260,6 +260,8 @@ objects: apiVersion: v1 metadata: name: gogs-postgres-data + labels: + app: ${APPLICATION_NAME} spec: accessModes: - ReadWriteOnce @@ -270,6 +272,8 @@ objects: apiVersion: v1 metadata: name: gogs-config + labels: + app: ${APPLICATION_NAME} data: app.ini: | RUN_MODE = prod @@ -287,6 +291,7 @@ objects: [server] ROOT_URL=http://${HOSTNAME} + SSH_DOMAIN=${HOSTNAME} [security] INSTALL_LOCK = ${INSTALL_LOCK} @@ -333,9 +338,12 @@ parameters: - displayName: Shared Buffer Amount name: DATABASE_SHARED_BUFFERS value: 12MB +- displayName: Database version (PostgreSQL) + name: DATABASE_VERSION + value: "9.5" - name: GOGS_VERSION displayName: Gogs Version - description: 'Version of the Gogs container image to be used (0.9.97 or 0.9.113)' + description: 'Version of the Gogs container image to be used (check the available version https://hub.docker.com/r/openshiftdemos/gogs/tags)' value: "0.9.97" required: true - name: INSTALL_LOCK diff --git a/openshift/gogs-template.yaml b/openshift/gogs-template.yaml index a8ad89f..929ef97 100644 --- a/openshift/gogs-template.yaml +++ b/openshift/gogs-template.yaml @@ -9,7 +9,6 @@ objects: - kind: ServiceAccount apiVersion: v1 metadata: - creationTimestamp: null labels: app: ${APPLICATION_NAME} name: ${APPLICATION_NAME} @@ -32,6 +31,8 @@ objects: annotations: description: Defines how to deploy the database name: ${APPLICATION_NAME}-postgresql + labels: + app: ${APPLICATION_NAME} spec: replicas: 1 selector: @@ -93,7 +94,7 @@ objects: - postgresql from: kind: ImageStreamTag - name: postgresql:9.4 + name: postgresql:${DATABASE_VERSION} namespace: openshift type: ImageChange - type: ConfigChange @@ -112,13 +113,15 @@ objects: port: 3000 protocol: TCP targetPort: 3000 + - name: 10022-tcp + port: 10022 + protocol: TCP + targetPort: 10022 selector: app: ${APPLICATION_NAME} deploymentconfig: ${APPLICATION_NAME} sessionAffinity: None type: ClusterIP - status: - loadBalancer: {} - kind: Route apiVersion: v1 id: ${APPLICATION_NAME}-http @@ -130,6 +133,23 @@ objects: name: ${APPLICATION_NAME} spec: host: ${HOSTNAME} + port: + targetPort: 3000-tcp + to: + name: ${APPLICATION_NAME} +- kind: Route + apiVersion: v1 + id: ${APPLICATION_NAME}-ssh + metadata: + annotations: + description: Route for application's ssh service. + labels: + app: ${APPLICATION_NAME} + name: ${APPLICATION_NAME}-ssh + spec: + host: secure${HOSTNAME} + port: + targetPort: 10022-tcp to: name: ${APPLICATION_NAME} - kind: DeploymentConfig @@ -167,6 +187,8 @@ objects: ports: - containerPort: 3000 protocol: TCP + - containerPort: 10022 + protocol: TCP resources: {} terminationMessagePath: /dev/termination-log volumeMounts: @@ -216,7 +238,7 @@ objects: - ${APPLICATION_NAME} from: kind: ImageStreamTag - name: ${APPLICATION_NAME}:latest + name: ${APPLICATION_NAME}:${GOGS_VERSION} type: ImageChange - kind: ImageStream apiVersion: v1 @@ -235,19 +257,12 @@ objects: description: The Gogs git server docker image tags: gogs,go,golang version: "${GOGS_VERSION}" - - annotations: - description: The Gogs git server docker image - tags: gogs,go,golang - version: "latest" - from: - kind: ImageStreamTag - name: "${GOGS_VERSION}" - importPolicy: {} - name: "latest" - kind: ConfigMap apiVersion: v1 metadata: name: gogs-config + labels: + app: ${APPLICATION_NAME} data: app.ini: | RUN_MODE = prod @@ -265,6 +280,9 @@ objects: [server] ROOT_URL=http://${HOSTNAME} + SSH_DOMAIN=secure${HOSTNAME} + START_SSH_SERVER=true + SSH_LISTEN_PORT=10022 [security] INSTALL_LOCK = ${INSTALL_LOCK} @@ -303,10 +321,13 @@ parameters: - displayName: Shared Buffer Amount name: DATABASE_SHARED_BUFFERS value: 12MB +- displayName: Database version (PostgreSQL) + name: DATABASE_VERSION + value: "9.5" - name: GOGS_VERSION displayName: Gogs Version - description: 'Version of the Gogs container image to be used (0.9.97 or 0.9.113)' - value: "0.9.97" + description: 'Version of the Gogs container image to be used (check the available version https://hub.docker.com/r/openshiftdemos/gogs/tags)' + value: "0.11.34" required: true - name: INSTALL_LOCK displayName: Installation lock diff --git a/root/usr/bin/rungogs b/root/usr/bin/rungogs index b3aa48e..8c56d32 100755 --- a/root/usr/bin/rungogs +++ b/root/usr/bin/rungogs @@ -9,5 +9,6 @@ echo "gogs:x:${USER_ID}:${GROUP_ID}:gogs.io user:${HOME}:/bin/bash" >> "$HOME/pa export LD_PRELOAD=libnss_wrapper.so export NSS_WRAPPER_PASSWD=${HOME}/passwd export NSS_WRAPPER_GROUP=/etc/group +export PORT=3000 /usr/bin/gogs run web