-
Notifications
You must be signed in to change notification settings - Fork 15
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
WIP Adding a toggleable additional Gitea external mirror #2071
Draft
craddm
wants to merge
48
commits into
alan-turing-institute:develop
Choose a base branch
from
craddm:gitea_external_mirror
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
e4a00ae
add gitea_external_server
craddm ce965cf
add additional files for external gitea
craddm fa62af6
Add gitea_external_mirror config flag
craddm cb70be7
Create enum for GiteaServerAvailability
craddm 73259e4
Create GiteaServerAvailability type
craddm 34b25cd
Add gitea_external_mirror to config template
craddm b218499
add gitea_server field to GiteaServerProps
craddm 15dcbf0
change gitea_external_mirror field entry to list
craddm 7f5c04c
add gitea_servers field to SREUserServiceProps
craddm 2acba92
change gitea enum name and possible responses
craddm 39845fe
change GiteaServer type
craddm 700f6f2
Change use of GiteaServers enum
craddm 4042d1e
Change GiteaServer Enum possible values
craddm 27f0c00
Iterate over gitea_servers to deploy multiple types
craddm 26b5f47
Modify config template
craddm ebcc502
Remove seperate gitea component for external mirror
craddm a9643f1
Switch to boolean toggle for external mirror
craddm 5fa097b
Remove GiteaServers enum
craddm 3adc136
Change gitea flag to boolean
craddm 3a20cc8
Use new fieldname
craddm dfbaf54
Switch to boolean toggle for external mirror
craddm d9067f9
Run lint:fmt
craddm 4705e22
Switch to boolean toggle and change logic for deploying multiple servers
craddm 5ab174d
Merge branch 'alan-turing-institute:develop' into gitea_external_mirror
craddm b6f3a50
remove deprecated enum
craddm d8e7ee5
switch to external_git_mirror
craddm 486261e
rename gitea property
craddm da2b231
comment out external subnet while testing
craddm cb242ac
comment out external subnet while testing
craddm d499684
use separate fileshares for external and internal gitea servers
craddm 599f771
don't setup ldap on external gitea server
craddm a575e71
Merge remote-tracking branch 'upstream/develop' into gitea_external_m…
craddm 0d32339
fix linting error
craddm 426c6d6
Add ip range for external git mirror
craddm 424b18b
add subnet and nsg for external git mirror
craddm c86beec
add enum for git mirror nsg rule
craddm 52badd4
differentiate between internal and external gitea hosts
craddm 92669fc
add some test NSG rules
craddm 343b20c
differentiate between internal and external gitea servers
craddm 3b7e1f9
create list of gitea servers
craddm e8d3488
add type hint
craddm 72e7cc1
swap gitea over
craddm 638982b
Merge remote-tracking branch 'upstream/develop' into gitea_external_m…
craddm cf31e76
Capture gitea hostnames correctly
craddm dfb6d7e
Use dicts rather than lists for gitea server related variables
craddm b53ac70
Fix setting hostnames for external and internal gitea
craddm 36a8cd6
populate gitea_hostnames
craddm 53c88a7
Merge branch 'alan-turing-institute:develop' into gitea_external_mirror
craddm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ def __init__( | |
database_subnet_id: Input[str], | ||
dns_server_ip: Input[str], | ||
dockerhub_credentials: DockerHubCredentials, | ||
gitea_server: Input[str], | ||
ldap_server_hostname: Input[str], | ||
ldap_server_port: Input[int], | ||
ldap_username_attribute: Input[str], | ||
|
@@ -49,6 +50,7 @@ def __init__( | |
) | ||
self.dns_server_ip = dns_server_ip | ||
self.dockerhub_credentials = dockerhub_credentials | ||
self.gitea_server = gitea_server | ||
self.ldap_server_hostname = ldap_server_hostname | ||
self.ldap_server_port = ldap_server_port | ||
self.ldap_username_attribute = ldap_username_attribute | ||
|
@@ -82,7 +84,7 @@ def __init__( | |
access_tier=storage.ShareAccessTier.TRANSACTION_OPTIMIZED, | ||
account_name=props.storage_account_name, | ||
resource_group_name=props.resource_group_name, | ||
share_name="gitea-caddy", | ||
share_name=f"{props.gitea_server}-gitea-caddy", | ||
share_quota=1, | ||
signed_identifiers=[], | ||
opts=child_opts, | ||
|
@@ -92,7 +94,7 @@ def __init__( | |
access_tier=storage.ShareAccessTier.TRANSACTION_OPTIMIZED, | ||
account_name=props.storage_account_name, | ||
resource_group_name=props.resource_group_name, | ||
share_name="gitea-gitea", | ||
share_name=f"{props.gitea_server}-gitea-gitea", | ||
share_quota=1, | ||
signed_identifiers=[], | ||
opts=child_opts, | ||
|
@@ -117,9 +119,14 @@ def __init__( | |
) | ||
|
||
# Upload Gitea configuration script | ||
gitea_configure_sh_reader = FileReader( | ||
resources_path / "gitea" / "gitea" / "configure.mustache.sh" | ||
) | ||
if props.gitea_server == "external": | ||
gitea_configure_sh_reader = FileReader( | ||
resources_path / "gitea_external" / "gitea" / "configure.mustache.sh" | ||
) | ||
else: | ||
gitea_configure_sh_reader = FileReader( | ||
resources_path / "gitea" / "gitea" / "configure.mustache.sh" | ||
) | ||
gitea_configure_sh = Output.all( | ||
admin_email="[email protected]", | ||
admin_username="dshadmin", | ||
|
@@ -167,12 +174,12 @@ def __init__( | |
# Define a PostgreSQL server and default database | ||
db_gitea_repository_name = "gitea" | ||
db_server_gitea = PostgresqlDatabaseComponent( | ||
f"{self._name}_db_gitea", | ||
f"{self._name}_db_gitea_{props.gitea_server}", | ||
PostgresqlDatabaseProps( | ||
database_names=[db_gitea_repository_name], | ||
database_password=props.database_password, | ||
database_resource_group_name=props.resource_group_name, | ||
database_server_name=f"{stack_name}-db-server-gitea", | ||
database_server_name=f"{stack_name}-db-server-gitea-{props.gitea_server}", | ||
database_subnet_id=props.database_subnet_id, | ||
database_username=props.database_username, | ||
disable_secure_transport=False, | ||
|
@@ -182,10 +189,10 @@ def __init__( | |
tags=child_tags, | ||
) | ||
|
||
# Define the container group with guacd, guacamole and caddy | ||
# Define the container group with gitea and caddy | ||
container_group = containerinstance.ContainerGroup( | ||
f"{self._name}_container_group", | ||
container_group_name=f"{stack_name}-container-group-gitea", | ||
container_group_name=f"{stack_name}-container-group-gitea-{props.gitea_server}", | ||
containers=[ | ||
containerinstance.ContainerArgs( | ||
image="caddy:2.8.4", | ||
|
@@ -341,7 +348,7 @@ def __init__( | |
LocalDnsRecordProps( | ||
base_fqdn=props.sre_fqdn, | ||
private_ip_address=get_ip_address_from_container_group(container_group), | ||
record_name="gitea", | ||
record_name=f"{props.gitea_server}-gitea", | ||
resource_group_name=props.resource_group_name, | ||
), | ||
opts=ResourceOptions.merge( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Refer to the Caddy docs for more information: | ||
# https://caddyserver.com/docs/caddyfile | ||
{ | ||
log { | ||
format console { | ||
level_format upper | ||
} | ||
level DEBUG | ||
} | ||
} | ||
|
||
:80 { | ||
reverse_proxy http://localhost:3000 | ||
} |
8 changes: 8 additions & 0 deletions
8
data_safe_haven/resources/gitea_external/gitea/configure.mustache.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#! /usr/bin/env bash | ||
|
||
# Ensure that default admin user exists | ||
until su-exec "$USER" /usr/local/bin/gitea admin user list --admin | grep "{{admin_username}}" > /dev/null 2>&1; do | ||
echo "$(date -Iseconds) Attempting to create default admin user '{{admin_username}}'..." | tee -a /var/log/configuration | ||
su-exec "$USER" /usr/local/bin/gitea admin user create --admin --username "{{admin_username}}" --random-password --random-password-length 20 --email "{{admin_email}}" 2> /dev/null | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#! /usr/bin/env sh | ||
|
||
# Add configuration as an s6 target | ||
mkdir -p /etc/s6/setup | ||
rm /etc/s6/setup/run 2> /dev/null | ||
ln -s /app/custom/configure.sh /etc/s6/setup/run | ||
|
||
# Run the usual entrypoint | ||
/usr/bin/entrypoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We
probably don't wantdon't need the external server to plug in to our LDAP directory.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some notes on Gitea configuration here