Change docker tag logic #16421

Merged
lunny merged 5 commits from docker-changes into main 2021-07-14 17:08:43 +00:00
5 changed files with 197 additions and 24 deletions

@ -691,7 +691,7 @@ steps:
---
kind: pipeline
name: docker-linux-amd64-release
name: docker-linux-amd64-release-version
platform:
os: linux
@ -703,7 +703,6 @@ depends_on:
trigger:
ref:
- refs/heads/main
- "refs/tags/**"
event:
exclude:
@ -754,6 +753,70 @@ steps:
exclude:
- pull_request
---
kind: pipeline
name: docker-linux-amd64-release
platform:
os: linux
arch: amd64
depends_on:
- testing-amd64
- testing-arm64
trigger:
ref:
- refs/heads/main
event:
exclude:
- cron
steps:
- name: fetch-tags
image: docker:git
commands:
- git fetch --tags --force
- name: publish
pull: always
image: techknowlogick/drone-docker:latest
settings:
auto_tag: false
tags: dev-linux-amd64
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
when:
event:
exclude:
- pull_request
- name: publish-rootless
image: techknowlogick/drone-docker:latest
settings:
dockerfile: Dockerfile.rootless
auto_tag: false
tags: dev-linux-amd64-rootless
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
- pull_request
---
kind: pipeline
name: docker-linux-arm64-dry-run
@ -788,7 +851,7 @@ steps:
---
kind: pipeline
name: docker-linux-arm64-release
name: docker-linux-arm64-release-version
platform:
os: linux
@ -800,7 +863,6 @@ depends_on:
trigger:
ref:
- refs/heads/main
- "refs/tags/**"
event:
exclude:
@ -856,7 +918,73 @@ steps:
---
kind: pipeline
name: docker-manifest
name: docker-linux-arm64-release
platform:
os: linux
arch: arm64
depends_on:
- testing-amd64
- testing-arm64
trigger:
ref:
- refs/heads/main
event:
exclude:
- cron
steps:
- name: fetch-tags
image: docker:git
commands:
- git fetch --tags --force
- name: publish
pull: always
image: techknowlogick/drone-docker:latest
settings:
auto_tag: false
tags: dev-linux-arm64
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
- pull_request
- name: publish-rootless
image: techknowlogick/drone-docker:latest
settings:
dockerfile: Dockerfile.rootless
auto_tag: false
tags: dev-linux-arm64-rootless
repo: gitea/gitea
build_args:
- GOPROXY=off
password:
from_secret: docker_password
username:
from_secret: docker_username
environment:
PLUGIN_MIRROR:
from_secret: plugin_mirror
when:
event:
exclude:
- pull_request
---
kind: pipeline
name: docker-manifest-version
platform:
os: linux
@ -888,12 +1016,54 @@ steps:
trigger:
ref:
- refs/heads/main
- "refs/tags/**"
event:
exclude:
- cron
depends_on:
- docker-linux-amd64-release-version
- docker-linux-arm64-release-version
---
kind: pipeline
name: docker-manifest
platform:
os: linux
arch: amd64
steps:
- name: manifest-rootless
pull: always
image: plugins/manifest
settings:
auto_tag: false
ignore_missing: true
spec: docker/manifest.rootless.tmpl
password:
from_secret: docker_password

Does this need the fetch-tags step since we are not using version tags in the docker build step?

Not sure if the dockerfiles need tags for RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}";, but if I understand the logic, if [ -n "${GITEA_VERSION}" ] should always resolve false here for dev build.

Does this need the `fetch-tags` step since we are not using version tags in the docker build step? Not sure if the dockerfiles need tags for `RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}";`, but if I understand the logic, `if [ -n "${GITEA_VERSION}" ]` should always resolve false here for dev build.

It does need the fetch-tags logic, as otherwise we can't generate a version based on git information (eg. 1.15.0+dev-582-g3dcb3e907).

It does need the fetch-tags logic, as otherwise we can't generate a version based on git information (eg. `1.15.0+dev-582-g3dcb3e907`).
username:
from_secret: docker_username
- name: manifest
image: plugins/manifest
settings:
auto_tag: false
ignore_missing: true
spec: docker/manifest.tmpl
password:
from_secret: docker_password
username:
from_secret: docker_username
trigger:
ref:
- refs/heads/main
event:
exclude:
- cron
depends_on:
- docker-linux-amd64-release
- docker-linux-arm64-release
@ -927,7 +1097,10 @@ depends_on:
- release-latest
- docker-linux-amd64-release
- docker-linux-arm64-release
- docker-linux-amd64-release-version
- docker-linux-arm64-release-version
- docker-manifest
- docker-manifest-version
- docs
steps:

@ -1,18 +1,19 @@
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}-rootless
{{/each}}
- "latest-rootless"
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
{{/if}}
manifests:
-
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
platform:
architecture: amd64
os: linux
-
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
platform:
architecture: arm64
os: linux

    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless

For consistency with the image logic above

```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-amd64-rootless ``` For consistency with the image logic above
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```
    image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless
```suggestion image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}-linux-arm64-rootless ```

@ -1,19 +1,20 @@
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}dev{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
- "latest"
{{/if}}
manifests:
-
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}dev-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
-
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
image: gitea/gitea:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}dev-{{/if}}linux-arm64
platform:
architecture: arm64
os: linux
variant: v8
variant: v8

@ -32,15 +32,14 @@ image as a service. Since there is no database available, one can be initialized
Create a directory for `data` and `config` then paste the following content into a file named `docker-compose.yml`.
Note that the volume should be owned by the user/group with the UID/GID specified in the config file. By default Gitea in docker will use uid:1000 gid:1000. If needed you can set ownership on those folders with the command: `sudo chown 1000:1000 config/ data/`
If you don't give the volume correct permissions, the container may not start.
Also be aware that the tag `:latest-rootless` will install the current development version.
For a stable release you can use `:1-rootless` or specify a certain release like `:{{< version >}}-rootless`.
For a stable release you could use `:latest-rootless`, `:1-rootless` or specify a certain release like `:{{< version >}}-rootless`, but if you'd like to use the latest development version then `:dev-rootless` would be an appropriate tag.
```yaml
version: "2"
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
restart: always
volumes:
- ./data:/var/lib/gitea

latest-rootless should still work, right? Or are you just suggesting people version-lock their docker-compose files?

`latest-rootless` should still work, right? Or are you just suggesting people version-lock their docker-compose files?

Yup, it still works, but your assumption of what I was doing was correct. This also aligns with what the other page has.

Yup, it still works, but your assumption of what I was doing was correct. This also aligns with what the other page has.
@ -63,7 +62,7 @@ version: "2"
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
restart: always
volumes:
- ./data:/var/lib/gitea
@ -87,7 +86,7 @@ version: "2"
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
+ environment:
+ - GITEA__database__DB_TYPE=mysql
+ - GITEA__database__HOST=db:3306
@ -128,7 +127,7 @@ version: "2"
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
environment:
+ - GITEA__database__DB_TYPE=postgres
+ - GITEA__database__HOST=db:5432
@ -174,7 +173,7 @@ version: "2"
+
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
restart: always
volumes:
- - ./data:/var/lib/gitea
@ -201,7 +200,7 @@ version: "2"
services:
server:
image: gitea/gitea:latest-rootless
image: gitea/gitea:{{< version >}}-rootless
restart: always
+ user: 1001
volumes:
@ -262,7 +261,7 @@ docker-compose up -d
- Rename folder (inside volume) gitea to custom
- Edit app.ini if needed
- Set START_SSH_SERVER = true
- Use image gitea/gitea:latest-rootless
- Use image gitea/gitea:{{< version >}}-rootless
## Managing Deployments With Environment Variables

@ -34,8 +34,7 @@ image as a service. Since there is no database available, one can be initialized
Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`.
Note that the volume should be owned by the user/group with the UID/GID specified in the config file.
If you don't give the volume correct permissions, the container may not start.
Also be aware that the tag `:latest` will install the current development version.
For a stable release you can use `:1` or specify a certain release like `:{{< version >}}`.
For a stable release you can use `:latest`, `:1` or specify a certain release like `:{{< version >}}`, but if you'd like to use the latest development version of Gitea then you could use the `:dev` tag.
```yaml
version: "3"