add searxng

This commit is contained in:
Andras Bacsai 2022-10-20 09:44:08 +02:00
parent 22cbbec960
commit 978e35d335
3 changed files with 18 additions and 13 deletions

View File

@ -716,10 +716,10 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
// ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}), // ...(exposePort ? { ports: [`${exposePort}:${port}`] } : {}),
volumes: template.services[service].volumes, volumes: template.services[service].volumes,
environment: newEnviroments, environment: newEnviroments,
depends_on: template.services[service].depends_on, depends_on: template.services[service]?.depends_on,
ulimits: template.services[service].ulimits, ulimits: template.services[service]?.ulimits,
cap_drop: template.services[service].cap_drop, cap_drop: template.services[service]?.cap_drop,
cap_add: template.services[service].cap_add, cap_add: template.services[service]?.cap_add,
labels: makeLabelForServices(type), labels: makeLabelForServices(type),
...defaultComposeConfiguration(network), ...defaultComposeConfiguration(network),
} }
@ -752,6 +752,7 @@ export async function startService(request: FastifyRequest<ServiceStartStop>) {
} }
const composeFileDestination = `${workdir}/docker-compose.yaml`; const composeFileDestination = `${workdir}/docker-compose.yaml`;
await fs.writeFile(composeFileDestination, yaml.dump(composeFile)); await fs.writeFile(composeFileDestination, yaml.dump(composeFile));
console.log(composeFileDestination)
await startServiceContainers(destinationDocker.id, composeFileDestination) await startServiceContainers(destinationDocker.id, composeFileDestination)
return {} return {}
} catch ({ status, message }) { } catch ({ status, message }) {

View File

@ -8,12 +8,16 @@ export default [
"services": { "services": {
"$$id": { "$$id": {
"name": "SearXNG", "name": "SearXNG",
"build": {
context: "$$workdir",
dockerfile: "Dockerfile.$$id"
},
"depends_on": [ "depends_on": [
"$$id-redis" "$$id-redis"
], ],
"image": "searxng/searxng:$$core_version", "image": "searxng/searxng:$$core_version",
"volumes": [ "volumes": [
"$$id-postgresql-searxng:/etc/searxng", "$$id-searxng:/etc/searxng",
], ],
"environment": [ "environment": [
"SEARXNG_BASE_URL=$$config_searxng_base_url", "SEARXNG_BASE_URL=$$config_searxng_base_url",
@ -22,11 +26,13 @@ export default [
"ports": [ "ports": [
"8080" "8080"
], ],
"cap_drop": ['ALL'],
"cap_add": ['CHOWN', 'SETGID', 'SETUID', 'DAC_OVERRIDE'],
"extras": { "extras": {
"files": [ "files": [
{ {
source: "$$workdir/schema.postgresql.sql", source: "$$workdir/settings.yml",
destination: "/docker-entrypoint-initdb.d/schema.postgresql.sql", destination: "/etc/searxng/settings.yml",
content: ` content: `
# see https://docs.searxng.org/admin/engines/settings.html#use-default-settings # see https://docs.searxng.org/admin/engines/settings.html#use-default-settings
use_default_settings: true use_default_settings: true

View File

@ -157,23 +157,21 @@ export async function parseAndFindServiceTemplates(service: any, workdir?: strin
const { name, value } = setting const { name, value } = setting
const regex = new RegExp(`\\$\\$config_${name}\\"`, 'gi') const regex = new RegExp(`\\$\\$config_${name}\\"`, 'gi')
if (service.fqdn && value === '$$generate_fqdn') { if (service.fqdn && value === '$$generate_fqdn') {
parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, service.fqdn + "\"")) parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, service.fqdn+ "\""))
} else if (service.fqdn && value === '$$generate_domain') { } else if (service.fqdn && value === '$$generate_domain') {
parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, getDomain(service.fqdn) + "\"")) parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, getDomain(service.fqdn)+ "\""))
} else { } else {
parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, value + "\"")) parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regex, value + "\""))
} }
} }
} }
// replace $$secret // replace $$secret
if (service.serviceSecret.length > 0) { if (service.serviceSecret.length > 0) {
for (const secret of service.serviceSecret) { for (const secret of service.serviceSecret) {
const { name, value } = secret const { name, value } = secret
const regex = new RegExp(`\\$\\$secret_${name}\\"`, 'gi') parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(`$$hashed$$secret_${name.toLowerCase()}`, bcrypt.hashSync(value, 10)).replaceAll(`$$secret_${name.toLowerCase()}`, value))
const regexHashed = new RegExp(`\\$\\$hashed\\$\\$secret_${name}\\"`, 'gi')
parsedTemplate = JSON.parse(JSON.stringify(parsedTemplate).replaceAll(regexHashed, bcrypt.hashSync(value, 10)).replaceAll(regex, value))
} }
} }
} }