Skip to content

[WIP] Feature/docker updates #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
FROM alpine:3.3
MAINTAINER [email protected]
FROM alpine:3.4

# Install system utils & Gogs runtime dependencies
MAINTAINER Rachid Zarouali <[email protected]>

# Install system utils & gitea runtime dependencies
ADD https://github.com/tianon/gosu/releases/download/1.9/gosu-amd64 /usr/sbin/gosu
RUN chmod +x /usr/sbin/gosu \
&& apk --no-cache --no-progress add ca-certificates bash git linux-pam s6 curl openssh socat tzdata

ENV GITEA_CUSTOM /data/gogs
ENV GITEA_CUSTOM /data/gitea

COPY . /app/gogs/
WORKDIR /app/gogs/
RUN ./docker/build.sh
COPY . /app/gitea/
WORKDIR /app/gitea/

# Configure LibC Name Service
COPY docker/nsswitch.conf /etc/nsswitch.conf

# creating data folder tree
RUN mkdir -p /data/gitea/data /data/gitea/conf /data/gitea/log /data/git /data/ssh

# Configure Docker Container
VOLUME ["/data"]
EXPOSE 22 3000
ENTRYPOINT ["docker/start.sh"]
CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]
CMD ["/bin/s6-svscan", "/app/gitea/docker/s6/"]
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](http://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
[![Join the chat at https://gitter.im/go-gitea/gitea](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-gitea/gitea?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

![](https://github.com/go-gitea/gitea/blob/master/public/img/gogs-large-resize.png?raw=true)
![](https://github.com/go-gitea/gitea/blob/master/public/img/gitea-large-resize.png?raw=true)

##### Current tip version: 0.9.99 (see [Releases](https://github.com/go-gitea/gitea/releases) for binary versions or submit a task on [alpha stage automated binary building system](https://build.gogs.io/))
##### Status

**Current version: 1.0.0** (see [Releases](https://github.com/go-gitea/gitea/releases))

| Web | UI | Preview |
|:-------------:|:-------:|:-------:|
Expand All @@ -19,25 +21,14 @@

### Important Notes

1. **YOU MUST READ [Contributing Code](https://github.com/go-gitea/gitea/wiki/Contributing-Code) BEFORE STARTING TO WORK ON A PULL REQUEST**.
2. Due to testing purpose, data of [try.gogs.io](https://try.gogs.io) was reset in **Jan 28, 2015** and will reset multiple times after. Please do **NOT** put your important data on the site.
3. The demo site [try.gogs.io](https://try.gogs.io) is running under `develop` branch.
4. If you think there are vulnerabilities in the project, please talk privately to **[email protected]**. Thanks!
5. If you're interested in using APIs, we have experimental support with [documentation](https://godoc.org/github.com/go-gitea/go-sdk).
6. If your team/company is using Gogs and would like to put your logo on [our website](https://gogs.io), contact us by any means.
1. **YOU MUST READ THE [Contributors Guide](https://github.com/go-gitea/gitea/CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST**.
4. If you think there are vulnerabilities in the project, please talk privately to **[email protected]**. Thanks!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the list numbers ;)

6. If your team/company is using Gogs and would like to put your logo on [our website](https://gitea.io), contact us by any means.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gogs :trollface:


## Purpose

The goal of this project is to make the easiest, fastest, and most painless way of setting up a self-hosted Git service. With Go, this can be done with an independent binary distribution across **ALL platforms** that Go supports, including Linux, Mac OS X, Windows and ARM.

## Overview

- Please see the [Documentation](https://gogs.io/docs/intro) for common usages and change log.
- See the [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team.
- Want to try it before doing anything else? Do it [online](https://try.gogs.io/gogs/gogs)!
- Having trouble? Get help with [Troubleshooting](https://gogs.io/docs/intro/troubleshooting.html) or [User Forum](https://discuss.gogs.io/).
- Want to help with localization? Check out the [guide](https://gogs.io/docs/features/i18n.html)!

## Features

- Activity timeline
Expand Down Expand Up @@ -69,15 +60,14 @@ The goal of this project is to make the easiest, fastest, and most painless way

## Installation

Make sure you install the [prerequisites](https://gogs.io/docs/installation) first.
**Note: As Gitea is a [Gogs](https://github.com/gogits/gogs) fork, tutorials and documentation related to gogs applies to Gitea too**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gogs should be Capitalized :)


There are 5 ways to install Gogs:
There are 2 ways to install Gitea:

- [Install from binary](https://gogs.io/docs/installation/install_from_binary.html)
- [Install from source](https://gogs.io/docs/installation/install_from_source.html)
- [Install from packages](https://gogs.io/docs/installation/install_from_packages.html)
- [Ship with Docker](https://github.com/go-gitea/gitea/tree/master/docker)
- [Install with Vagrant](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs)
- [Install with Vagrant](https://github.com/go-gitea/examples/tree/master/vagrant)

**Note: binary release will be available soon**

### Tutorials

Expand Down Expand Up @@ -133,7 +123,7 @@ There are 5 ways to install Gogs:

## Contributors

- Ex-team members [@lunny](https://github.com/lunny), [@fuxiaohei](https://github.com/fuxiaohei) and [@slene](https://github.com/slene).
- see [Maintainer page](https://github.com/orgs/go-gitea/people)
- See [contributors page](https://github.com/go-gitea/gitea/graphs/contributors) for full list of contributors.
- See [TRANSLATORS](conf/locale/TRANSLATORS) for public list of translators.

Expand Down
66 changes: 27 additions & 39 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# Docker for Gogs
# Docker for Gitea

Visit [Docker Hub](https://hub.docker.com/r/gogs/) see all available images and tags.
Visit [Docker Hub](https://hub.docker.com/r/gitea/) see all available images and tags.

## Usage

To keep your data out of Docker container, we do a volume (`/var/gogs` -> `/data`) here, and you can change it based on your situation.
To keep your data out of Docker container, we do a volume (`/var/gitea` -> `/data`) here, and you can change it based on your situation.

```
# Pull image from Docker Hub.
$ docker pull gogs/gogs
$ docker pull gitea/gitea

# Create local directory for volume.
$ mkdir -p /var/gogs
$ mkdir -p /var/gitea

# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs
$ docker run --name=gitea -p 10022:22 -p 10080:3000 -v /var/gitea:/data gitea/gitea

# Use `docker start` if you have stopped it.
$ docker start gogs
$ docker start gitea
```

Note: It is important to map the Gogs ssh service from the container to the host and set the appropriate SSH Port and URI settings when setting up Gogs for the first time. To access and clone Gogs Git repositories with the above configuration you would use: `git clone ssh://git@hostname:10022/username/myrepo.git` for example.
Note: It is important to map the gitea ssh service from the container to the host and set the appropriate SSH Port and URI settings when setting up gitea for the first time. To access and clone gitea Git repositories with the above configuration you would use: `git clone ssh://git@hostname:10022/username/myrepo.git` for example.

Files will be store in local path `/var/gogs` in my case.
Files will be store in local path `/var/gitea` in my case.

Directory `/var/gogs` keeps Git repositories and Gogs data:
Directory `/var/gitea` keeps Git repositories and gitea data:

/var/gogs
/var/gitea
|-- git
| |-- gogs-repositories
| |-- gitea-repositories
|-- ssh
| |-- # ssh public/private keys for Gogs
|-- gogs
| |-- # ssh public/private keys for gitea
|-- gitea
|-- conf
|-- data
|-- log
Expand All @@ -42,51 +42,39 @@ If you're more comfortable with mounting data to a data container, the commands

```
# Create data container
docker run --name=gogs-data --entrypoint /bin/true gogs/gogs
docker run --name=gitea-data --entrypoint /bin/true gitea/gitea

# Use `docker run` for the first time.
docker run --name=gogs --volumes-from gogs-data -p 10022:22 -p 10080:3000 gogs/gogs
docker run --name=gitea --volumes-from gitea-data -p 10022:22 -p 10080:3000 gitea/gitea
```

#### Using Docker 1.9 Volume command
#### Using Docker Volume command

```
# Create docker volume.
$ docker volume create --name gogs-data
$ docker volume create --name gitea-data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's techincally no need for this, since docker run will auto-create it if it doesn't exist


# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:22 -p 10080:3000 -v gogs-data:/data gogs/gogs
$ docker run --name=gitea -p 10022:22 -p 10080:3000 -v gitea-data:/data gitea/gitea
```

## Settings

### Application

Most of settings are obvious and easy to understand, but there are some settings can be confusing by running Gogs inside Docker:
Most of settings are obvious and easy to understand, but there are some settings can be confusing by running gitea inside Docker:

- **Repository Root Path**: keep it as default value `/home/git/gogs-repositories` because `start.sh` already made a symbolic link for you.
- **Repository Root Path**: keep it as default value `/home/git/gitea-repositories` because `start.sh` already made a symbolic link for you.
- **Run User**: keep it as default value `git` because `start.sh` already setup a user with name `git`.
- **Domain**: fill in with Docker container IP (e.g. `192.168.99.100`). But if you want to access your Gogs instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine.
- **Domain**: fill in with Docker container IP (e.g. `192.168.99.100`). But if you want to access your gitea instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine.
- **SSH Port**: Use the exposed port from Docker container. For example, your SSH server listens on `22` inside Docker, but you expose it by `10022:22`, then use `10022` for this value. **Builtin SSH server is not recommended inside Docker Container**
- **HTTP Port**: Use port you want Gogs to listen on inside Docker container. For example, your Gogs listens on `3000` inside Docker, and you expose it by `10080:3000`, but you still use `3000` for this value.
- **HTTP Port**: Use port you want gitea to listen on inside Docker container. For example, your gitea listens on `3000` inside Docker, and you expose it by `10080:3000`, but you still use `3000` for this value.
- **Application URL**: Use combination of **Domain** and **exposed HTTP Port** values (e.g. `http://192.168.99.100:10080/`).

Full documentation of application settings can be found [here](https://gogs.io/docs/advanced/configuration_cheat_sheet.html).

### Container options

This container have some options available via environment variables, these options are opt-in features that can help the administration of this container:

- **SOCAT_LINK**:
- <u>Possible value:</u>
`true`, `false`, `1`, `0`
- <u>Default:</u>
`true`
- <u>Action:</u>
Bind linked docker container to localhost socket using socat.
Any exported port from a linked container will be binded to the matching port on localhost.
- <u>Disclaimer:</u>
As this option rely on the environment variable created by docker when a container is linked, this option should be deactivated in managed environment such as Rancher or Kubernetes (set to `0` or `false`)
- **RUN_CROND**:
- <u>Possible value:</u>
`true`, `false`, `1`, `0`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has socat-support been removed?

Expand All @@ -99,11 +87,11 @@ This container have some options available via environment variables, these opti

:exclamation::exclamation::exclamation:<span style="color: red">**Make sure you have volumed data to somewhere outside Docker container**</span>:exclamation::exclamation::exclamation:

Steps to upgrade Gogs with Docker:
Steps to upgrade gitea with Docker:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gitea capitalized


- `docker pull gogs/gogs`
- `docker stop gogs`
- `docker rm gogs`
- `docker pull gitea/gitea`
- `docker stop gitea`
- `docker rm gitea`
- Finally, create container as the first time and don't forget to do same volume and port mapping.

## Known Issues
Expand Down
36 changes: 0 additions & 36 deletions docker/build.sh

This file was deleted.

48 changes: 0 additions & 48 deletions docker/start.sh
Original file line number Diff line number Diff line change
@@ -1,53 +1,5 @@
#!/bin/sh

create_socat_links() {
# Bind linked docker container to localhost socket using socat
USED_PORT="3000:22"
while read NAME ADDR PORT; do
if test -z "$NAME$ADDR$PORT"; then
continue
elif echo $USED_PORT | grep -E "(^|:)$PORT($|:)" > /dev/null; then
echo "init:socat | Can't bind linked container ${NAME} to localhost, port ${PORT} already in use" 1>&2
else
SERV_FOLDER=/app/gogs/docker/s6/SOCAT_${NAME}_${PORT}
mkdir -p ${SERV_FOLDER}
CMD="socat -ls TCP4-LISTEN:${PORT},fork,reuseaddr TCP4:${ADDR}:${PORT}"
echo -e "#!/bin/sh\nexec $CMD" > ${SERV_FOLDER}/run
chmod +x ${SERV_FOLDER}/run
USED_PORT="${USED_PORT}:${PORT}"
echo "init:socat | Linked container ${NAME} will be binded to localhost on port ${PORT}" 1>&2
fi
done << EOT
$(env | sed -En 's|(.*)_PORT_([0-9]+)_TCP=tcp://(.*):([0-9]+)|\1 \3 \4|p')
EOT
}

cleanup() {
# Cleanup SOCAT services and s6 event folder
# On start and on shutdown in case container has been killed
rm -rf $(find /app/gogs/docker/s6/ -name 'event')
rm -rf /app/gogs/docker/s6/SOCAT_*
}

create_volume_subfolder() {
# Create VOLUME subfolder
for f in /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/ssh; do
if ! test -d $f; then
mkdir -p $f
fi
done
}

cleanup
create_volume_subfolder

LINK=$(echo "$SOCAT_LINK" | tr '[:upper:]' '[:lower:]')
if [ "$LINK" = "false" -o "$LINK" = "0" ]; then
echo "init:socat | Will not try to create socat links as requested" 1>&2
else
create_socat_links
fi

CROND=$(echo "$RUN_CROND" | tr '[:upper:]' '[:lower:]')
if [ "$CROND" = "true" -o "$CROND" = "1" ]; then
echo "init:crond | Cron Daemon (crond) will be run as requested by s6" 1>&2
Expand Down
Binary file modified public/img/avatar_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/gitea-large-resize.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/gitea-lg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.