diff --git a/src/infra_version.js b/src/infra_version.js index a9e19fe67..03cae5b60 100644 --- a/src/infra_version.js +++ b/src/infra_version.js @@ -17,7 +17,7 @@ exports = module.exports = { 'images': { 'turn': { repo: 'cloudron/turn', tag: 'cloudron/turn:1.3.1@sha256:759cafab7625ff538418a1f2ed5558b1d5bff08c576bba577d865d6d02b49091' }, 'mysql': { repo: 'cloudron/mysql', tag: 'cloudron/mysql:3.0.7@sha256:6679c2fb96f8d6d62349b607748570640a90fc46b50aad80ca2c0161655d07f4' }, - 'postgresql': { repo: 'cloudron/postgresql', tag: 'cloudron/postgresql:4.1.1@sha256:86e4e2f4fd43809efca7c9cb1def4d7608cf36cb9ea27052f9b64da4481db43a' }, + 'postgresql': { repo: 'cloudron/postgresql', tag: 'cloudron/postgresql:4.2.0@sha256:121b3ca245cae28461ea96014fde5bb8b6bdfb79584aaebc2f1f77b6c25285c6' }, 'mongodb': { repo: 'cloudron/mongodb', tag: 'cloudron/mongodb:4.1.1@sha256:77538cb576158b7e12983d9dd13475d5173d16d398e31693a681999eb94f278a' }, 'redis': { repo: 'cloudron/redis', tag: 'cloudron/redis:3.1.1@sha256:7b3a28f777ba0a664fd8defa6748190c63ad364ade58c61d23183bef87c9b4a8' }, 'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.6.0@sha256:f67c3659d5122153f746f009e3a61a49619f95b838f357fcdf02024276252036' }, diff --git a/src/services.js b/src/services.js index a1a612967..c968ad0e0 100644 --- a/src/services.js +++ b/src/services.js @@ -593,7 +593,7 @@ async function waitForContainer(containerName, tokenEnvName) { await promiseRetry({ times: 10, interval: 15000, debug }, async () => { // temporary workaround till we move all containers to http - const url = containerName.includes('redis') || containerName === 'mongodb' + const url = containerName.includes('redis') || containerName === 'mongodb' || containerName === 'postgresql' ? `http://${result.ip}:3000/healthcheck?access_token=${result.token}` : `https://${result.ip}:3000/healthcheck?access_token=${result.token}`; @@ -1427,8 +1427,7 @@ async function setupPostgreSql(app, options) { const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN'); - const [networkError, response] = await safe(superagent.post(`https://${result.ip}:3000/databases?access_token=${result.token}`) - .disableTLSCerts() + const [networkError, response] = await safe(superagent.post(`http://${result.ip}:3000/databases?access_token=${result.token}`) .send(data) .ok(() => true)); if (networkError) throw new BoxError(BoxError.ADDONS_ERROR, `Network error setting up postgresql: ${networkError.message}`); @@ -1458,8 +1457,7 @@ async function clearPostgreSql(app, options) { const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN'); - const [networkError, response] = await safe(superagent.post(`https://${result.ip}:3000/databases/${database}/clear?access_token=${result.token}&username=${username}&locale=${locale}`) - .disableTLSCerts() + const [networkError, response] = await safe(superagent.post(`http://${result.ip}:3000/databases/${database}/clear?access_token=${result.token}&username=${username}&locale=${locale}`) .ok(() => true)); if (networkError) throw new BoxError(BoxError.ADDONS_ERROR, `Network error clearing postgresql: ${networkError.message}`); if (response.status !== 200) throw new BoxError(BoxError.ADDONS_ERROR, `Error clearing postgresql. Status code: ${response.status} message: ${response.body.message}`); @@ -1473,8 +1471,7 @@ async function teardownPostgreSql(app, options) { const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN'); - const [networkError, response] = await safe(superagent.del(`https://${result.ip}:3000/databases/${database}?access_token=${result.token}&username=${username}`) - .disableTLSCerts() + const [networkError, response] = await safe(superagent.del(`http://${result.ip}:3000/databases/${database}?access_token=${result.token}&username=${username}`) .ok(() => true)); if (networkError) throw new BoxError(BoxError.ADDONS_ERROR, `Network error tearing down postgresql: ${networkError.message}`); if (response.status !== 200) throw new BoxError(BoxError.ADDONS_ERROR, `Error tearing down postgresql. Status code: ${response.status} message: ${response.body.message}`); @@ -1491,9 +1488,7 @@ async function backupPostgreSql(app, options) { const { database } = postgreSqlNames(app.id); const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN'); - - const url = `https://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`; - await pipeRequestToFile(url, dumpPath('postgresql', app.id)); + await pipeRequestToFile2(`http://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`, dumpPath('postgresql', app.id)); } async function restorePostgreSql(app, options) { @@ -1506,21 +1501,7 @@ async function restorePostgreSql(app, options) { const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN'); - await new Promise((resolve, reject) => { - resolve = once(resolve); // protect from multiple returns with streams - - const input = fs.createReadStream(dumpPath('postgresql', app.id)); - input.on('error', (error) => reject(new BoxError(BoxError.FS_ERROR, `Error reading input stream when restoring postgresql: ${error.message}`))); - - const restoreReq = request.post(`https://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}&username=${username}`, { json: true, rejectUnauthorized: false }, function (error, response) { - if (error) return reject(new BoxError(BoxError.ADDONS_ERROR, `Error restoring postgresql: ${error.message}`)); - if (response.statusCode !== 200) return reject(new BoxError(BoxError.ADDONS_ERROR, `Error restoring postgresql. Status code: ${response.statusCode} message: ${response.body.message}`)); - - resolve(); - }); - - input.pipe(restoreReq); - }); + await pipeFileToRequest(dumpPath('postgresql', app.id), `http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}&username=${username}`); } async function startMongodb(existingInfra) {