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

Clone instructions do not respect SSH_DOMAIN variable when set as an environment variable #19453

Closed
darth-veitcher opened this issue Apr 21, 2022 · 2 comments · Fixed by #25648
Labels

Comments

@darth-veitcher
Copy link

Description

I'm running with the docker image and have the following set as environment variables. The idea being to have a separate domain for ssh cloning of repositories as the primary domain goes via Cloudflare proxy (and therefore blocks the SSH protocol).

# file: docker-compose.yaml
gitea:
    image: gitea/gitea
    container_name: gitea
    hostname: git.mydomain.tld
    restart: always
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=postgres
      - DB_HOST=db:5432
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
      # Customise
      - GITEA____APP_NAME="My Gitea Instance"
      - GITEA__server__DOMAIN="git.mydomain.tld"
      - GITEA__server__ROOT_URL="https://git.mydomain.tld"
      - GITEA__server__SSH_DOMAIN="clone.mydomain.tld"
    networks:
      - gitea
    volumes:
      - ./data/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      - db
      - redis
      - minio

On creating a new repository however I'm getting presenting with a SSH clone url which reflects the DOMAIN as opposed to the SSH_DOMAIN.

On investigation it seems as though this environment variable has not been respected and passed through to the underlying app.ini. If login into the container and inspect the file it shows the following:

# file: /data/gitea/conf/app.ini
...
[server]
APP_DATA_PATH    = /data/gitea
DOMAIN           = git.mydomain.tld
SSH_DOMAIN       = git.mydomain.tld
...

If I manually edit this file inside the container to adjust the SSH_DOMAIN variable and restart it then the setting is respected.

Gitea Version

1.16.5 built with GNU Make 4.3, go1.18 : bindata, timetzdata, sqlite, sqlite_unlock_notify

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?

Gitea is running with docker and docker-compose using image: gitea/gitea

Database

PostgreSQL

@mike1936
Copy link

Voting up this issue.
Neither [server] DOMAIN nor [server] SSH_DOMAIN.
Version 1.17.1

@zeripath
Copy link
Contributor

zeripath commented Feb 8, 2023

The only way this could not be working is if you're running the install page.

Why are you running the install page on every container restart?

silverwind pushed a commit that referenced this issue Jul 9, 2023
Replace #25580

Fix #19453

The problem was: when users set "GITEA__XXX__YYY" , the "install page"
doesn't respect it.

So, to make the result consistent and avoid surprising end users, now
the "install page" also writes the environment variables to the config
file.

And, to make things clear, there are enough messages on the UI to tell
users what will happen.

There are some necessary/related changes to `environment-to-ini.go`:

* The "--clear" flag is removed and it was incorrectly written there.
The "clear" operation should be done if INSTALL_LOCK=true
* The "--prefix" flag is removed because it's never used, never
documented and it only causes inconsistent behavior.


![image](https://github.com/go-gitea/gitea/assets/2114189/12778ee4-3fb5-4664-a73a-41ebbd77cd5b)
wxiaoguang added a commit to wxiaoguang/gitea that referenced this issue Jul 10, 2023
Replace go-gitea#25580

Fix go-gitea#19453

The problem was: when users set "GITEA__XXX__YYY" , the "install page"
doesn't respect it.

So, to make the result consistent and avoid surprising end users, now
the "install page" also writes the environment variables to the config
file.

And, to make things clear, there are enough messages on the UI to tell
users what will happen.

There are some necessary/related changes to `environment-to-ini.go`:

* The "--clear" flag is removed and it was incorrectly written there.
The "clear" operation should be done if INSTALL_LOCK=true
* The "--prefix" flag is removed because it's never used, never
documented and it only causes inconsistent behavior.

![image](https://github.com/go-gitea/gitea/assets/2114189/12778ee4-3fb5-4664-a73a-41ebbd77cd5b)
# Conflicts:
#	templates/install.tmpl
KN4CK3R pushed a commit that referenced this issue Jul 10, 2023
Backport #25648

Replace #25580

Fix #19453

The problem was: when users set "GITEA__XXX__YYY" , the "install page"
doesn't respect it.

So, to make the result consistent and avoid surprising end users, now
the "install page" also writes the environment variables to the config
file.

And, to make things clear, there are enough messages on the UI to tell
users what will happen.

There are some necessary/related changes to `environment-to-ini.go`:

* The "--clear" flag is removed and it was incorrectly written there.
The "clear" operation should be done if INSTALL_LOCK=true
* The "--prefix" flag is removed because it's never used, never
documented and it only causes inconsistent behavior.

The only conflict during backport is "ui divider" in
templates/install.tmpl
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants