Skip to content
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

Changing to rootless image triggers gitea to offer a new install - Can i change to keep my data? #21647

Closed
neszt opened this issue Oct 31, 2022 · 4 comments
Labels

Comments

@neszt
Copy link

neszt commented Oct 31, 2022

Description

I use docker image 1.17.3. I would like to switch to 1.17.3-rootless. After starting, gitea offers a new install on web surface.

Is there a way to keep my data?

Gitea Version

1.17.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

With Docker compose.

# cat docker-compose.yml
version: "3.3"
services:
  server:
    restart: always
    image: gitea/gitea:${GITEA_VERSION}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /usr/share/zoneinfo:/usr/share/zoneinfo:ro
      - ${DATA}:/data
    ports:
      - "${HTTP_PORT}:3000"
      - "${SSH_PORT}:22"
# cat .env
GITEA_VERSION=1.17.3
HTTP_PORT=3000
SSH_PORT=2222
DATA=./data

Database

No response

@zeripath
Copy link
Contributor

There are some slight differences in the places that the rootless docker and the root docker stores things.

I can't start docker right now to check but you should be able to pull some imges and create a test bed to see how to change your compose file etc.

@zeripath
Copy link
Contributor

zeripath commented Nov 1, 2022

So there's some basic information here: https://docs.gitea.io/en-us/install-with-docker-rootless/#upgrading-from-standard-image


But we can examine things a bit further, if we run a docker run gitea/gitea:latest & gitea/gitea:latest-rootless and look at /usr/local/bin/gitea to find the default app.ini we see that the rootful docker uses:

  • $GITEA_WORK_DIR = /app/gitea
  • $GITEA_CUSTOM = /data/gitea
  • The app.ini is fixed as $GITEA_CUSTOM/conf/app.ini, i.e. usually /data/gitea/conf/app.ini.
  • Within the app.ini we see:
    • [repository].ROOT = /data/git/repositories
    • [repository.local].LOCAL_COPY_PATH = /data/gitea/tmp/local-repo
    • [server].APP_DATA_PATH = /data/gitea
    • [database].PATH = /data/gitea/gitea.db
    • [lfs].PATH = /data/git/lfs
    • plus some others under /data/gitea too i.e. come from $GITEA_CUSTOM

Whereas the rootless docker uses:

  • $WORK_DIR = /var/lib/gitea
  • $GITEA_CUSTOM_PATH is not directly set but it becomes /var/lib/gitea/data
  • the app.ini can be set directly as $GITEA_APP_INI and defaults to /etc/gitea/app.ini
  • Within the app.ini we see:
    • [repository].ROOT = /var/lib/gitea/git/repositories
    • [repository.local].LOCAL_COPY_PATH = /tmp/gitea/local-repo <- This is $GITEA_TEMP/local-repo
    • [server].APP_DATA_PATH = /var/lib/gitea
    • [database].PATH = /var/lib/gitea/gitea.db
    • [lfs].PATH = /var/lib/gitea/data/git/lfs
    • plus some others under /var/lib/gitea/data too i.e. come from $GITEA_CUSTOM

So how would one convert from the root docker to the rootless docker?

  • Either move the app.ini from /data/gitea/conf/app.ini to /etc/gitea/app.ini, or when running the docker ensure that the environment variable GITEA_APP_INI is set to /data/gitea/conf/app.ini
  • Set the environment variable GITEA_TEMP to /data/gitea/tmp, or change app.ini values that have /data/gitea/tmp in them to /tmp/gitea and expect that temporary files will go there.
  • Set the environment variable GITEA_CUSTOM to /data/gitea, or change app.ini values and move things from /data/gitea to /var/lib/gitea
  • Set the environment variable GITEA_WORK_DIR to /app/gitea/gitea

Why do we have to do this? Unfortunately these decisions were made a long time ago and it would be very breaking to change things at this point. If we could it would be good to realign things to try to make things more consistent but I'm not sure how to get there.

@neszt
Copy link
Author

neszt commented Nov 1, 2022

Thanks for the excellent help, I modified docker compose and now it works perfectly even with a rootless image!

version: "3.3"
services:
  server:
    restart: always
    image: gitea/gitea:${GITEA_VERSION}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /usr/share/zoneinfo:/usr/share/zoneinfo:ro
      - ${DATA}:/data
    environment:
      - GITEA_APP_INI=/data/gitea/conf/app.ini
      - GITEA_TEMP=/data/gitea/tmp
      - GITEA_CUSTOM=/data/gitea
      - GITEA_WORK_DIR=/app/gitea/gitea
    ports:
      - "${HTTP_PORT}:3000"
      - "${SSH_PORT}:22"

I'm just writing as an interesting fact that the whole problem was brought up because the separated ssh server does not accept my ssh key while the builtin ssh server does. The error message was:

server_1  | userauth_pubkey: signature algorithm ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
server_1  | userauth_pubkey: signature algorithm ssh-dss not in PubkeyAcceptedAlgorithms [preauth]

@wxiaoguang
Copy link
Contributor

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants