diff --git a/.gitignore b/.gitignore index acd374d8b..da8ad566b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,6 @@ node_modules/ -nginx/sourcegraph.crt -nginx/sourcegraph.key - .vagrant *.log /.env diff --git a/docker-compose/db-only-migrate.docker-compose.yaml b/docker-compose/db-only-migrate.docker-compose.yaml index 372876701..5df29445b 100644 --- a/docker-compose/db-only-migrate.docker-compose.yaml +++ b/docker-compose/db-only-migrate.docker-compose.yaml @@ -1,6 +1,7 @@ # This file contains the pgsql service definition (the primary Sourcegraph database deployment), # as well as the codeintel-db service definition (a separate postgres deployment). Both run postgres. -# This file is used during the sourcegraph/server -> docker-compose migration process. +# This file is used for database-only operations such as backup and restore. +# See https://sourcegraph.com/docs/self-hosted/deploy/docker-compose/operations # # 🚨This file MUST be kept in sync with the pgsql definition in docker-compose/docker-compose.yaml version: '2.4' diff --git a/go.mod b/go.mod index f1e6ab114..b92ce5013 100644 --- a/go.mod +++ b/go.mod @@ -5,14 +5,11 @@ go 1.19 require ( github.com/Masterminds/semver v1.5.0 github.com/sourcegraph/run v0.12.0 - github.com/sourcegraph/sourcegraph/dev/ci/images v0.0.0-20240222005846-e3158c0c2717 - github.com/sourcegraph/update-docker-tags v0.10.0 github.com/urfave/cli/v2 v2.25.7 ) require ( bitbucket.org/creachadair/shell v0.0.7 // indirect - github.com/Masterminds/semver/v3 v3.1.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/djherbis/buffer v1.2.0 // indirect github.com/djherbis/nio/v3 v3.0.1 // indirect @@ -20,7 +17,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/itchyny/gojq v0.12.11 // indirect github.com/itchyny/timefmt-go v0.1.5 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/rogpeppe/go-internal v1.8.1 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect diff --git a/go.sum b/go.sum index 616ac9a8e..7439a245f 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ bitbucket.org/creachadair/shell v0.0.7 h1:Z96pB6DkSb7F3Y3BBnJeOZH2gazyMTWlvecSD4 bitbucket.org/creachadair/shell v0.0.7/go.mod h1:oqtXSSvSYr4624lnnabXHaBsYW6RD80caLi2b3hJk0U= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/semver/v3 v3.1.0 h1:Y2lUDsFKVRSYGojLJ1yLxSXdMmMYTYls0rCvoqmMUQk= -github.com/Masterminds/semver/v3 v3.1.0/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -37,8 +35,6 @@ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxec github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/nightlyone/lockfile v1.0.0 h1:RHep2cFKK4PonZJDdEl4GmkabuhbsRMgk/k3uAmxBiA= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= @@ -46,12 +42,6 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sourcegraph/run v0.12.0 h1:3A8w5e8HIYPfafHekvmdmmh42RHKGVhmiTZAPJclg7I= github.com/sourcegraph/run v0.12.0/go.mod h1:PwaP936BTnAJC1cqR5rSbG5kOs/EWStTK3lqvMX5GUA= -github.com/sourcegraph/sourcegraph/dev/ci/images v0.0.0-20231101211343-d046aeda10e4 h1:Mi4SkXsHkJBGrzbrarAU0gCT/GpwP4OnAVrqynAUjoQ= -github.com/sourcegraph/sourcegraph/dev/ci/images v0.0.0-20231101211343-d046aeda10e4/go.mod h1:HpOGaRM0iHPNrEQvpB4/3E9dAUjutyhgjg9vrOOeXPY= -github.com/sourcegraph/sourcegraph/dev/ci/images v0.0.0-20240222005846-e3158c0c2717 h1:xzO3kAjylr2urK0w5Yu95n98jSwpTQ4w/rvf8QA5pwY= -github.com/sourcegraph/sourcegraph/dev/ci/images v0.0.0-20240222005846-e3158c0c2717/go.mod h1:HpOGaRM0iHPNrEQvpB4/3E9dAUjutyhgjg9vrOOeXPY= -github.com/sourcegraph/update-docker-tags v0.10.0 h1:KpY1HtvSt0FzDM/sR0jQF5StNbiPKpqmHhE0jpBEa0A= -github.com/sourcegraph/update-docker-tags v0.10.0/go.mod h1:lCDsoUnk/ASDbm7UxE7tU3qAUhQxA7xykELHXcLeKFM= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= diff --git a/nginx/nginx.conf b/nginx/nginx.conf deleted file mode 100644 index 9a3af5476..000000000 --- a/nginx/nginx.conf +++ /dev/null @@ -1,53 +0,0 @@ -# @sourcegraph: This file should be kept in sync with https://github.com/sourcegraph/sourcegraph/blob/main/cmd/server/shared/assets/nginx.conf -# -# You can adjust the configuration to add additional TLS or HTTP features. -# Read more at https://docs.sourcegraph.com/admin/nginx - -error_log stderr; -pid /var/run/nginx.pid; - -# Do not remove. The contents of sourcegraph_main.conf can change between -# versions and may include improvements to the configuration. -include nginx/sourcegraph_main.conf; - -events { -} - -http { - server_tokens off; - - # SAML redirect response headers are sometimes large - proxy_buffer_size 128k; - proxy_buffers 8 256k; - proxy_busy_buffers_size 256k; - - # Do not remove. The contents of sourcegraph_http.conf can change between - # versions and may include improvements to the configuration. - include nginx/sourcegraph_http.conf; - - access_log off; - upstream backend { - # Do not remove. The contents of sourcegraph_backend.conf can change - # between versions and may include improvements to the configuration. - include nginx/sourcegraph_backend.conf; - } - - server { - # Do not remove. The contents of sourcegraph_server.conf can change - # between versions and may include improvements to the configuration. - include nginx/sourcegraph_server.conf; - - listen 7080; - location / { - proxy_pass http://backend; - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # SAML redirect response headers are sometimes large - proxy_buffer_size 128k; - proxy_buffers 8 256k; - proxy_busy_buffers_size 256k; - } - } -} diff --git a/nginx/nginx/sourcegraph_backend.conf b/nginx/nginx/sourcegraph_backend.conf deleted file mode 100644 index d2450fbb1..000000000 --- a/nginx/nginx/sourcegraph_backend.conf +++ /dev/null @@ -1,8 +0,0 @@ -# @sourcegraph: This file was adapted from https://github.com/sourcegraph/sourcegraph/blob/main/cmd/server/shared/assets/nginx/sourcegraph_backend.conf -# -# Do not remove. This config is included in the upstream context for backend by -# nginx.conf - -# Nginx round-robins between all of the sourcegraph-frontend service endpoints listed here. -# Add/remove 'sourcegraph-frontend-x' addresses here when changing the number of replicas. -server sourcegraph-frontend-0:3080; diff --git a/nginx/nginx/sourcegraph_http.conf b/nginx/nginx/sourcegraph_http.conf deleted file mode 100644 index de9f34b3b..000000000 --- a/nginx/nginx/sourcegraph_http.conf +++ /dev/null @@ -1,9 +0,0 @@ -# @sourcegraph: This file should be kept in sync with https://github.com/sourcegraph/sourcegraph/blob/main/cmd/server/shared/assets/nginx/sourcegraph_http.conf -# -# Do not remove. The contents of sourcegraph_http.conf can change between -# versions and may include improvements to the configuration. -# -# This config is included in the http context by nginx.conf - -# We can upload large extensions -client_max_body_size 150M; diff --git a/nginx/nginx/sourcegraph_main.conf b/nginx/nginx/sourcegraph_main.conf deleted file mode 100644 index 39538dfd6..000000000 --- a/nginx/nginx/sourcegraph_main.conf +++ /dev/null @@ -1,8 +0,0 @@ -# @sourcegraph: This file should be kept in sync with https://github.com/sourcegraph/sourcegraph/blob/main/cmd/server/shared/assets/nginx/sourcegraph_main.conf -# -# Do not remove. The contents of sourcegraph_main.conf can change between -# versions and may include improvements to the configuration. -# -# This config is included in the main context by nginx.conf - -# Intentionally blank diff --git a/nginx/nginx/sourcegraph_server.conf b/nginx/nginx/sourcegraph_server.conf deleted file mode 100644 index b2cdde8ef..000000000 --- a/nginx/nginx/sourcegraph_server.conf +++ /dev/null @@ -1,5 +0,0 @@ -# @sourcegraph: This file should be kept in sync with https://github.com/sourcegraph/sourcegraph/blob/main/cmd/server/shared/assets/nginx/sourcegraph_server.conf -# -# Do not modify. - -# Intentionally blank diff --git a/renovate.json b/renovate.json index a58a74a9c..bbd0f43d0 100644 --- a/renovate.json +++ b/renovate.json @@ -21,12 +21,6 @@ "ignoreUnstable": false, "semanticCommits": false, "automerge": true - }, - { - "groupName": "Sourcegraph Docker images list", - "packagePatterns": ["github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images"], - "allowedVersions": "~=0.0.0", - "automerge": true } ], "masterIssue": true, diff --git a/tools/migrate.sh b/tools/migrate.sh deleted file mode 100755 index 3bffdba9e..000000000 --- a/tools/migrate.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# Please ensure the variables in migration vars have been assigned before running this script. - -set -euxo pipefail - -( -# shellcheck source=migration_vars -source migration_vars -) - -image=${image:-sourcegraph/server} -sg_dump_file=$(mktemp) -codeintel_dump_file=$(mktemp) - -trap 'rm -f ${sg_dump_file} ${codeintel_dump_file}' EXIT - -# Get the ID of the sourcegraph container -echo "Obtaing sourcegraph container ID" -container_id=$(ssh "${src_host}" docker ps | grep "${image}:${version}" | cut -f 1 -d ' ') - -# Dump sourcegraph db and alter script for migration -echo "Dumping sourcegraph database" -ssh ${src_host} "docker exec ${container_id} pg_dump -C --username=postgres sourcegraph" >${sg_dump_file} -sed -i '/^CREATE DATABASE/a CREATE USER postgres WITH SUPERUSER CREATEROLE CREATEDB REPLICATION BYPASSRLS;' ${sg_dump_file} >/dev/null 2>&1 -printf '\connect -reuse-previous=on dbname=postgres\nDROP DATABASE sg;\nALTER DATABASE "sourcegraph" RENAME TO sg;\nALTER DATABASE sg OWNER TO sg;\n' >>${sg_dump_file} - -# Dump codeintel db and alter script for migration -echo "Dumping codeintel database" -ssh ${src_host} "docker exec ${container_id} pg_dump -C --username=postgres sourcegraph-codeintel" >${codeintel_dump_file} -sed -i '/^CREATE DATABASE/a CREATE USER postgres WITH SUPERUSER CREATEROLE CREATEDB REPLICATION BYPASSRLS;' ${codeintel_dump_file} >/dev/null 2>&1 -printf '\connect -reuse-previous=on dbname=postgres\nDROP DATABASE sg;\nALTER DATABASE "sourcegraph-codeintel" RENAME TO sg;\nALTER DATABASE sg OWNER TO sg;\n' >>${codeintel_dump_file} - -# Upload database dumps to new docker-compose deployment -echo "Uploading dumps to new deployment" -chmod 544 ${sg_dump_file} ${codeintel_dump_file} -scp ${sg_dump_file} "${dst_host}:${sg_dump_file}" -scp ${codeintel_dump_file} "${dst_host}:${codeintel_dump_file}" - -# Migrate databases and start new deployment -ssh -t "${dst_host}" " -pushd ${compose_dir} -docker-compose down --volumes -docker-compose -f db-only-migrate.docker-compose.yaml up -d -sleep 10 -docker cp ${sg_dump_file} pgsql:${sg_dump_file} -docker cp ${codeintel_dump_file} codeintel-db:${codeintel_dump_file} - -echo 'Starting migration' -docker exec pgsql sh -c 'psql -v ERROR_ON_STOP=1 -U sg -f ${sg_dump_file} postgres' -docker exec codeintel-db sh -c 'psql -v ERROR_ON_STOP=1 -U sg -f ${codeintel_dump_file} postgres' - -docker-compose -f docker-compose.yaml up -d -echo 'TEST: Checking frontend is accessible for 1 minute' - -for i in {1..6}; do -curl -f http://localhost:80 -curl -f http://localhost:80/healthz -sleep 10 -done -echo 'Migration completed' -" diff --git a/tools/migration_vars b/tools/migration_vars deleted file mode 100644 index 198058cb3..000000000 --- a/tools/migration_vars +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -set -u - -# Please populate the following variables with details of your migration - -# The name of the sourcegraph server image. Defaults to "sourcegraph/server" -IMAGE= - -# The sourcegraph version running on both the source and destination hosts. NOTE: this version must be the same when migration data ie : 3.24.1 -VERSION= - -# The username and hostname of the host you will be migrating from. Takes the form of username@host ie: sourcegraph-user@myhost -SRC_HOST= - -# The username and hostname of the host you will be migrating too. Takes the form of username@host ie: sourcegraph-user@myhost -DST_HOST= - -# Fully qualified path to the docker-compose directory on a host -COMPOSE_DIR= diff --git a/tools/tools.go b/tools/tools.go deleted file mode 100644 index c2dae5113..000000000 --- a/tools/tools.go +++ /dev/null @@ -1,8 +0,0 @@ -//+build tools - -package tools - -import ( - // pins update-docker-tags CLI - _ "github.com/sourcegraph/update-docker-tags" -)