Skip to content

Commit e95ba54

Browse files
authored
Merge branch 'master' into attachment_allow_prefix
2 parents 278d852 + 9add96a commit e95ba54

File tree

599 files changed

+15468
-19799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

599 files changed

+15468
-19799
lines changed

.dockerignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

Dockerfile

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1+
2+
###################################
3+
#Build stage
4+
FROM golang:1.10-alpine3.7 AS build-env
5+
6+
ARG GITEA_VERSION
7+
ARG TAGS="sqlite"
8+
ENV TAGS "bindata $TAGS"
9+
10+
#Build deps
11+
RUN apk --no-cache add build-base git
12+
13+
#Setup repo
14+
COPY . ${GOPATH}/src/code.gitea.io/gitea
15+
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
16+
17+
#Checkout version if set
18+
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
19+
&& make clean generate build
20+
121
FROM alpine:3.7
2-
LABEL maintainer="The Gitea Authors"
22+
LABEL maintainer="[email protected]"
323

424
EXPOSE 22 3000
525

626
RUN apk --no-cache add \
7-
su-exec \
8-
ca-certificates \
9-
sqlite \
1027
bash \
28+
ca-certificates \
29+
curl \
30+
gettext \
1131
git \
1232
linux-pam \
13-
s6 \
14-
curl \
1533
openssh \
16-
gettext \
34+
s6 \
35+
sqlite \
36+
su-exec \
1737
tzdata
38+
1839
RUN addgroup \
1940
-S -g 1000 \
2041
git && \
@@ -29,12 +50,11 @@ RUN addgroup \
2950

3051
ENV USER git
3152
ENV GITEA_CUSTOM /data/gitea
32-
ENV GODEBUG=netdns=go
3353

3454
VOLUME ["/data"]
3555

3656
ENTRYPOINT ["/usr/bin/entrypoint"]
3757
CMD ["/bin/s6-svscan", "/etc/s6"]
3858

3959
COPY docker /
40-
COPY gitea /app/gitea/gitea
60+
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ David Schneiderbauer <[email protected]> (@daviian)
2121
Peter Žeby <[email protected]> (@morlinest)
2222
Matti Ranta <[email protected]> (@techknowlogick)
2323
Michael Lustfield <[email protected]> (@MTecknology)
24+
Jonas Franz <[email protected]> (@JonasFranzDEV)

cmd/generate.go

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Copyright 2016 The Gogs Authors. All rights reserved.
2+
// Copyright 2016 The Gitea Authors. All rights reserved.
3+
// Use of this source code is governed by a MIT-style
4+
// license that can be found in the LICENSE file.
5+
6+
package cmd
7+
8+
import (
9+
"fmt"
10+
11+
"code.gitea.io/gitea/modules/generate"
12+
13+
"github.com/urfave/cli"
14+
)
15+
16+
var (
17+
// CmdGenerate represents the available generate sub-command.
18+
CmdGenerate = cli.Command{
19+
Name: "generate",
20+
Usage: "Command line interface for running generators",
21+
Subcommands: []cli.Command{
22+
subcmdSecret,
23+
},
24+
}
25+
26+
subcmdSecret = cli.Command{
27+
Name: "secret",
28+
Usage: "Generate a secret token",
29+
Subcommands: []cli.Command{
30+
microcmdGenerateInternalToken,
31+
microcmdGenerateLfsJwtSecret,
32+
microcmdGenerateSecretKey,
33+
},
34+
}
35+
36+
microcmdGenerateInternalToken = cli.Command{
37+
Name: "INTERNAL_TOKEN",
38+
Usage: "Generate a new INTERNAL_TOKEN",
39+
Action: runGenerateInternalToken,
40+
}
41+
42+
microcmdGenerateLfsJwtSecret = cli.Command{
43+
Name: "LFS_JWT_SECRET",
44+
Usage: "Generate a new LFS_JWT_SECRET",
45+
Action: runGenerateLfsJwtSecret,
46+
}
47+
48+
microcmdGenerateSecretKey = cli.Command{
49+
Name: "SECRET_KEY",
50+
Usage: "Generate a new SECRET_KEY",
51+
Action: runGenerateSecretKey,
52+
}
53+
)
54+
55+
func runGenerateInternalToken(c *cli.Context) error {
56+
internalToken, err := generate.NewInternalToken()
57+
if err != nil {
58+
return err
59+
}
60+
61+
fmt.Printf("%s\n", internalToken)
62+
return nil
63+
}
64+
65+
func runGenerateLfsJwtSecret(c *cli.Context) error {
66+
JWTSecretBase64, err := generate.NewLfsJwtSecret()
67+
if err != nil {
68+
return err
69+
}
70+
71+
fmt.Printf("%s\n", JWTSecretBase64)
72+
return nil
73+
}
74+
75+
func runGenerateSecretKey(c *cli.Context) error {
76+
secretKey, err := generate.NewSecretKey()
77+
if err != nil {
78+
return err
79+
}
80+
81+
fmt.Printf("%s\n", secretKey)
82+
return nil
83+
}

custom/conf/app.ini.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ PATH = data/gitea.db
210210
SQLITE_TIMEOUT = 500
211211
; For iterate buffer, default is 50
212212
ITERATE_BUFFER_SIZE = 50
213+
; Show the database generated SQL
214+
LOG_SQL = true
213215

214216
[indexer]
215217
ISSUE_INDEXER_PATH = indexers/issues.bleve
@@ -299,6 +301,8 @@ DEFAULT_KEEP_EMAIL_PRIVATE = false
299301
; Default value for AllowCreateOrganization
300302
; New user will have rights set to create organizations depending on this setting
301303
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
304+
; Enable Timetracking
305+
ENABLE_TIMETRACKING = true
302306
; Default value for EnableTimetracking
303307
; Repositories will use timetracking by default depending on this setting
304308
DEFAULT_ENABLE_TIMETRACKING = true
@@ -553,6 +557,8 @@ DEFAULT_INTERVAL = 8h
553557
MIN_INTERVAL = 10m
554558

555559
[api]
560+
; Enables /api/swagger, /api/v1/swagger etc. endpoints. True or false; default is true.
561+
ENABLE_SWAGGER_ENDPOINT = true
556562
; Max number of items will response in a page
557563
MAX_RESPONSE_ITEMS = 50
558564

docker/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ DOCKER_REF := $(DOCKER_IMAGE):$(DOCKER_TAG)
77

88
.PHONY: docker
99
docker:
10-
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build
1110
docker build --disable-content-trust=false -t $(DOCKER_REF) .
11+
# support also build args docker build --build-arg GITEA_VERSION=v1.2.3 --build-arg TAGS="bindata sqlite" .
12+
13+
.PHONY: docker-build
14+
docker-build:
15+
docker run -ti --rm -v $(CURDIR):/srv/app/src/code.gitea.io/gitea -w /srv/app/src/code.gitea.io/gitea -e TAGS="bindata $(TAGS)" webhippie/golang:edge make clean generate build

docker/etc/s6/gitea/setup

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
/usr/sbin/update-ca-certificates
4+
35
if [ ! -d /data/git/.ssh ]; then
46
mkdir -p /data/git/.ssh
57
chmod 700 /data/git/.ssh

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typically be found at `/etc/gitea/conf/app.ini`.
2424

2525
The defaults provided here are best-effort (not built automatically). They are
2626
accurately recorded in [app.ini.sample](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample)
27-
(s/master/<tag|release\>). Any string in the format `%(X)s` is a feature powered
27+
(s/master/\<tag|release\>). Any string in the format `%(X)s` is a feature powered
2828
by [ini](https://github.com/go-ini/ini/#recursive-values), for reading values recursively.
2929

3030
Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
@@ -84,7 +84,9 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
8484

8585
- `PROTOCOL`: **http**: \[http, https, fcgi, unix\]
8686
- `DOMAIN`: **localhost**: Domain name of this server.
87-
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**: Full public URL of Gitea server.
87+
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
88+
Overwrite the automatically generated public URL.
89+
This is useful if the internal and the external URL don't match (e.g. in Docker).
8890
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
8991
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
9092
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
@@ -118,9 +120,10 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
118120
- `HOST`: **127.0.0.1:3306**: Database host address and port.
119121
- `NAME`: **gitea**: Database name.
120122
- `USER`: **root**: Database username.
121-
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password.
123+
- `PASSWD`: **\<empty\>**: Database user password. Use \`your password\` for quoting if you use special characters in the password.
122124
- `SSL_MODE`: **disable**: For PostgreSQL only.
123125
- `PATH`: **data/gitea.db**: For SQLite3 only, the database file path.
126+
- `LOG_SQL`: **true**: Log the executed SQL.
124127

125128
## Indexer (`indexer`)
126129

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ menu:
8080
- `PASSWD`: 数据库用户密码。
8181
- `SSL_MODE`: PostgreSQL数据库是否启用SSL模式。
8282
- `PATH`: Tidb 或者 SQLite3 数据文件存放路径。
83+
- `LOG_SQL`: **true**: 显示生成的SQL,默认为真。
8384

8485
## Security (`security`)
8586

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ the official [install instructions](https://docs.docker.com/compose/install/).
2828
The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest`
2929
image as a service. Since there is no database available one can be initialized using SQLite3.
3030
Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`.
31+
Note that the volume should be owned by the user/group with the UID/GID specified in the config file.
32+
If you don't give the volume correct permissions, the container may not start.
3133

3234
```yaml
3335
version: "2"
@@ -39,6 +41,9 @@ networks:
3941
services:
4042
server:
4143
image: gitea/gitea:latest
44+
environment:
45+
- USER_UID=1000
46+
- USER_GID=1000
4247
restart: always
4348
networks:
4449
- gitea
@@ -65,6 +70,9 @@ networks:
6570
services:
6671
server:
6772
image: gitea/gitea:latest
73+
environment:
74+
- USER_UID=1000
75+
- USER_GID=1000
6876
restart: always
6977
networks:
7078
- gitea
@@ -92,6 +100,9 @@ networks:
92100
services:
93101
server:
94102
image: gitea/gitea:latest
103+
environment:
104+
- USER_UID=1000
105+
- USER_GID=1000
95106
restart: always
96107
networks:
97108
- gitea
@@ -132,14 +143,17 @@ networks:
132143
services:
133144
server:
134145
image: gitea/gitea:latest
146+
environment:
147+
- USER_UID=1000
148+
- USER_GID=1000
135149
restart: always
136150
networks:
137151
- gitea
138152
volumes:
139153
- ./gitea:/data
140-
ports:
141-
- "3000:3000"
142-
- "222:22"
154+
ports:
155+
- "3000:3000"
156+
- "222:22"
143157
+ depends_on:
144158
+ - db
145159
+
@@ -160,7 +174,8 @@ services:
160174

161175
To use named volumes instead of host volumes, define and use the named volume
162176
within the `docker-compose.yml` configuration. This change will automatically
163-
create the required volume.
177+
create the required volume. You don't need to worry about permissions with
178+
named volumes, Docker will deal with that automatically.
164179

165180
```diff
166181
version: "2"
@@ -208,6 +223,27 @@ favorite browser to finalize the installation. Visit http://server-ip:3000 and f
208223
installation wizard. If the database was started with the `docker-compose` setup as
209224
documented above please note that `db` must be used as the database hostname.
210225

226+
## Environments variables
227+
228+
You can configure some of Gitea's settings via environment variables:
229+
230+
(Default values are provided in **bold**)
231+
232+
* `APP_NAME`: **"Gitea: Git with a cup of tea"**: Application name, used in the page title.
233+
* `RUN_MODE`: **dev**: For performance and other purposes, change this to `prod` when deployed to a production environment.
234+
* `SSH_DOMAIN`: **localhost**: Domain name of this server, used for displayed clone UR in Gitea's UI.
235+
* `SSH_PORT`: **22**: SSH port displayed in clone URL.
236+
* `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
237+
* `HTTP_PORT`: **3000**: HTTP listen port.
238+
* `ROOT_URL`: **""**: Overwrite the automatically generated public URL. This is useful if the internal and the external URL don't match (e.g. in Docker).
239+
* `DB_TYPE`: **sqlite3**: The database type in use \[mysql, postgres, mssql, sqlite3\].
240+
* `DB_HOST`: **localhost:3306**: Database host address and port.
241+
* `DB_NAME`: **gitea**: Database name.
242+
* `DB_USER`: **root**: Database username.
243+
* `DB_PASSWD`: **"<empty>"**: Database user password. Use \`your password\` for quoting if you use special characters in the password.
244+
* `INSTALL_LOCK`: **false**: Disallow access to the install page.
245+
* `SECRET_KEY`: **""**: Global secret key. This should be changed. If this has a value and `INSTALL_LOCK` is empty, `INSTALL_LOCK` will automatically set to `true`.
246+
211247
# Customization
212248

213249
Customization files described [here](https://docs.gitea.io/en-us/customizing-gitea/) should

docs/content/doc/upgrade/from-gogs.en-us.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ Gogs, version 0.9.146 and older, can be easily migrated to Gitea.
1919

2020
There are some basic steps to follow. On a Linux system run as the Gogs user:
2121

22-
* Create a Gogs backup with `gogs dump`. This creates `gogs-dump-[timestamp].zip` file
23-
containing all important Gogs data.
22+
* Create a Gogs backup with `gogs backup`. This creates `gogs-backup-[timestamp].zip` file
23+
containing all important Gogs data. You would need it if you wanted to move to the `gogs` back later.
2424
* Download the file matching the destination platform from the [downloads page](https://dl.gitea.io/gitea).
25+
It should be `1.0.x` version. Migrating from `gogs` to any other version is impossible.
2526
* Put the binary at the desired install location.
2627
* Copy `gogs/custom/conf/app.ini` to `gitea/custom/conf/app.ini`.
2728
* Copy custom `templates, public` from `gogs/custom/` to `gitea/custom/`.
@@ -38,6 +39,11 @@ There are some basic steps to follow. On a Linux system run as the Gogs user:
3839
* Rename `gogs-data/` to `gitea-data/`
3940
* In `gitea/custom/conf/app.ini` change:
4041

42+
### Upgrading to most recent `gitea` version:
43+
After successful migration from `gogs` to `gitea 1.0.x` it is possible to upgrade to the recent `gitea` version.
44+
Simply download the file matching the destination platform from the [downloads page](https://dl.gitea.io/gitea)
45+
and replace the binary.
46+
4147
FROM:
4248
```
4349
[database]

docs/content/doc/usage/command-line.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,19 @@ in the current directory.
9595
- Examples:
9696
- `gitea dump`
9797
- `gitea dump --verbose`
98+
99+
#### generate
100+
101+
Generates random values and tokens for usage in configuration file. Useful for generating values
102+
for automatic deployments.
103+
104+
- Commands:
105+
- `secret`:
106+
- Options:
107+
- `INTERNAL_TOKEN`: Token used for an internal API call authentication.
108+
- `LFS_JWT_SECRET`: LFS authentication secret.
109+
- `SECRET_KEY`: Global secret key.
110+
- Examples:
111+
- `gitea generate secret INTERNAL_TOKEN`
112+
- `gitea generate secret LFS_JWT_SECRET`
113+
- `gitea generate secret SECRET_KEY`

docs/content/page/index.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Windows, on architectures like amd64, i386, ARM, PowerPC, and others.
7474
- MSSQL
7575
- TiDB (experimental, not recommended)
7676
- Configuration file
77-
- [app.ini](https://github.com/go-gitea/gitea/blob/master/conf/app.ini)
77+
- [app.ini](https://github.com/go-gitea/gitea/blob/master/custom/conf/app.ini.sample)
7878
- Admin panel
7979
- Statistics
8080
- Actions

0 commit comments

Comments
 (0)