CI: add extra config file for easier per-deployment veriations, add hetzner deploy script

This commit is contained in:
Pieter Vander Vennet 2023-09-25 03:13:17 +02:00
parent 9d149cae30
commit fe3ccd1074
5 changed files with 40 additions and 12 deletions

3
config.json Normal file
View file

@ -0,0 +1,3 @@
{
"#": "Settings in this file override the `config`-section of `package.json`"
}

View file

@ -8,7 +8,8 @@
"main": "index.ts",
"type": "module",
"config": {
"#": "Various endpoints that are instance-specific",
"#": "Various endpoints that are instance-specific. This is the default configuration, which is re-exported in 'Constants.ts'.",
"#": "Use MAPCOMPLETE_CONFIGURATION to use an additional configuration, e.g. `MAPCOMPLETE_CONFIGURATION=config_hetzner`",
"#oauth_credentials:comment": [
"`oauth_credentials` are the OAuth-2 credentials for the production-OSM server and the test-server.",
"Are you deploying your own instance? Register your application too.",

View file

@ -0,0 +1,4 @@
{
"#":"Some configuration tweaks specifically for hetzner",
"country_coder_host": "https://countrycoder.mapcomplete.org/"
}

View file

@ -0,0 +1,20 @@
#! /bin/bash
### To be run from the root of the repository
# Some pointers to get started:
# apt install npm
# apt install unzip
# npm i -g csp-logger
# wget https://github.com/pietervdvn/latlon2country/raw/main/tiles.zip
# unzip tiles.zip
MAPCOMPLETE_CONFIGURATION="config_hetzner"
cp config.json config.json.bu &&
cp ./scripts/hetzner/config.json . &&
npm run prepare-deploy &&
mv config.json.bu config.json &&
zip dist.zip -r dist/* &&
scp -r dist.zip hetzner:/root/ &&
scp ./scripts/hetzner/config/* hetzner:/root/
ssh hetzner -t "unzip dist.zip && rm dist.zip && rm -rf public/ mv dist public && caddy stop && caddy start"

View file

@ -1,14 +1,11 @@
import * as meta from "../../package.json"
import * as packagefile from "../../package.json"
import * as extraconfig from "../../config.json"
import { Utils } from "../Utils"
export type PriviligedLayerType = (typeof Constants.priviliged_layers)[number]
export default class Constants {
public static vNumber = meta.version
public static ImgurApiKey = meta.config.api_keys.imgur
public static readonly mapillary_client_token_v4 = meta.config.api_keys.mapillary_v4
public static vNumber = packagefile.version
/**
* API key for Maproulette
*
@ -17,9 +14,6 @@ export default class Constants {
* Using an empty string however does work for most actions, but will attribute all actions to the Superuser.
*/
public static readonly MaprouletteApiKey = ""
public static defaultOverpassUrls = meta.config.default_overpass_urls
public static readonly added_by_default = [
"selected_element",
"gps_location",
@ -47,7 +41,6 @@ export default class Constants {
...Constants.added_by_default,
...Constants.no_include,
] as const
// The user journey states thresholds when a new feature gets unlocked
public static userJourney = {
moreScreenUnlock: 1,
@ -104,7 +97,14 @@ export default class Constants {
* In seconds
*/
static zoomToLocationTimeout = 15
static countryCoderEndpoint: string = meta.config.country_coder_host
private static readonly config = (() => {
const defaultConfig = packagefile.config
return { ...defaultConfig, ...extraconfig }
})()
public static ImgurApiKey = Constants.config.api_keys.imgur
public static readonly mapillary_client_token_v4 = Constants.config.api_keys.mapillary_v4
public static defaultOverpassUrls = Constants.config.default_overpass_urls
static countryCoderEndpoint: string = Constants.config.country_coder_host
/**
* These are the values that are allowed to use as 'backdrop' icon for a map pin