diff --git a/.vscode/settings.json b/.vscode/settings.json index 858d6ae2c..65a483d79 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,22 @@ { - "i18n-ally.localesPaths": ["src/lib/locales"], + "i18n-ally.localesPaths": [ + "src/lib/locales" + ], "i18n-ally.keystyle": "nested", "i18n-ally.extract.ignoredByFiles": { - "src\\routes\\__layout.svelte": ["Coolify", "coolLabs logo"] + "src\\routes\\__layout.svelte": [ + "Coolify", + "coolLabs logo" + ] }, "i18n-ally.sourceLanguage": "en", - "i18n-ally.enabledFrameworks": ["svelte"], - "i18n-ally.enabledParsers": ["js", "ts", "json"], + "i18n-ally.enabledFrameworks": [ + "svelte" + ], + "i18n-ally.enabledParsers": [ + "js", + "ts", + "json" + ], "i18n-ally.extract.autoDetect": true -} +} \ No newline at end of file diff --git a/apps/api/.env.example b/apps/api/.env.example index fcfaf2159..598d659b3 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -1,9 +1,9 @@ -COOLIFY_APP_ID=local-dev -# 32 bits long secret key -COOLIFY_SECRET_KEY=12341234123412341234123412341234 -COOLIFY_DATABASE_URL=file:../db/dev.db - -COOLIFY_IS_ON=docker -COOLIFY_WHITE_LABELED=false -COOLIFY_WHITE_LABELED_ICON= -COOLIFY_AUTO_UPDATE= \ No newline at end of file +COOLIFY_APP_ID=local-dev +# 32 bits long secret key +COOLIFY_SECRET_KEY=12341234123412341234123412341234 +COOLIFY_DATABASE_URL=file:../db/dev.db + +COOLIFY_IS_ON=docker +COOLIFY_WHITE_LABELED=false +COOLIFY_WHITE_LABELED_ICON= +COOLIFY_AUTO_UPDATE= diff --git a/apps/api/prisma/migrations/20221024204842_rollback_to_commit/migration.sql b/apps/api/prisma/migrations/20221024204842_rollback_to_commit/migration.sql new file mode 100644 index 000000000..aa8136ed8 --- /dev/null +++ b/apps/api/prisma/migrations/20221024204842_rollback_to_commit/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Application" ADD COLUMN "gitCommitHash" TEXT; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index 3cc460a28..9d5485deb 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -126,6 +126,7 @@ model Application { updatedAt DateTime @updatedAt destinationDockerId String? gitSourceId String? + gitCommitHash String? baseImage String? baseBuildImage String? gitSource GitSource? @relation(fields: [gitSourceId], references: [id]) diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts index 02609d844..09e92543a 100644 --- a/apps/api/src/jobs/deployApplication.ts +++ b/apps/api/src/jobs/deployApplication.ts @@ -169,6 +169,8 @@ import * as buildpacks from '../lib/buildPacks'; githubAppId: gitSource.githubApp?.id, gitlabAppId: gitSource.gitlabApp?.id, customPort: gitSource.customPort, + gitCommitHash: gitCommitHash, + configuration, repository, branch, buildId, diff --git a/apps/api/src/lib/importers/github.ts b/apps/api/src/lib/importers/github.ts index f42461939..f310c4704 100644 --- a/apps/api/src/lib/importers/github.ts +++ b/apps/api/src/lib/importers/github.ts @@ -9,6 +9,7 @@ export default async function ({ githubAppId, repository, apiUrl, + gitCommitHash, htmlUrl, branch, buildId, @@ -20,6 +21,7 @@ export default async function ({ githubAppId: string; repository: string; apiUrl: string; + gitCommitHash?: string; htmlUrl: string; branch: string; buildId: string; @@ -36,7 +38,7 @@ export default async function ({ applicationId }); await asyncExecShell( - `git clone -q -b ${branch} https://${url}/${repository}.git ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. ` + `git clone -q -b ${branch} https://${url}/${repository}.git ${workdir}/ && cd ${workdir} && git checkout ${gitCommitHash || "-"} && git submodule update --init --recursive && git lfs pull && cd .. ` ); } else { @@ -67,7 +69,7 @@ export default async function ({ applicationId }); await asyncExecShell( - `git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git --config core.sshCommand="ssh -p ${customPort}" ${workdir}/ && cd ${workdir} && git submodule update --init --recursive && git lfs pull && cd .. ` + `git clone -q -b ${branch} https://x-access-token:${token}@${url}/${repository}.git --config core.sshCommand="ssh -p ${customPort}" ${workdir}/ && cd ${workdir} && git checkout ${gitCommitHash || "-"} && git submodule update --init --recursive && git lfs pull && cd .. ` ); } const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`); diff --git a/apps/api/src/lib/importers/gitlab.ts b/apps/api/src/lib/importers/gitlab.ts index 35fa3d8ce..051e2a9d7 100644 --- a/apps/api/src/lib/importers/gitlab.ts +++ b/apps/api/src/lib/importers/gitlab.ts @@ -6,6 +6,7 @@ export default async function ({ workdir, repodir, htmlUrl, + gitCommitHash, repository, branch, buildId, @@ -20,6 +21,7 @@ export default async function ({ branch: string; buildId: string; repodir: string; + gitCommitHash: string; privateSshKey: string; customPort: number; forPublic: boolean; @@ -40,11 +42,11 @@ export default async function ({ if (forPublic) { await asyncExecShell( - `git clone -q -b ${branch} https://${url}/${repository}.git ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && git lfs pull && cd .. ` + `git clone -q -b ${branch} https://${url}/${repository}.git ${workdir}/ && cd ${workdir}/ && git checkout ${gitCommitHash || "-"} && git submodule update --init --recursive && git lfs pull && cd .. ` ); } else { await asyncExecShell( - `git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -p ${customPort} -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git submodule update --init --recursive && git lfs pull && cd .. ` + `git clone -q -b ${branch} git@${url}:${repository}.git --config core.sshCommand="ssh -p ${customPort} -q -i ${repodir}id.rsa -o StrictHostKeyChecking=no" ${workdir}/ && cd ${workdir}/ && git checkout ${gitCommitHash || "-"} && git submodule update --init --recursive && git lfs pull && cd .. ` ); } diff --git a/apps/api/src/routes/api/v1/applications/handlers.ts b/apps/api/src/routes/api/v1/applications/handlers.ts index 6dd16e2be..3ee5858ec 100644 --- a/apps/api/src/routes/api/v1/applications/handlers.ts +++ b/apps/api/src/routes/api/v1/applications/handlers.ts @@ -327,6 +327,7 @@ export async function saveApplication(request: FastifyRequest, dockerFileLocation, denoMainFile, denoOptions, + gitCommitHash, baseImage, baseBuildImage, deploymentType, @@ -366,6 +367,7 @@ export async function saveApplication(request: FastifyRequest, pythonVariable, denoOptions, baseImage, + gitCommitHash, baseBuildImage, deploymentType, dockerComposeFile, @@ -384,6 +386,7 @@ export async function saveApplication(request: FastifyRequest, exposePort, pythonWSGI, pythonModule, + gitCommitHash, pythonVariable, denoOptions, baseImage, diff --git a/apps/api/src/routes/api/v1/applications/types.ts b/apps/api/src/routes/api/v1/applications/types.ts index b282b0647..a11e6356d 100644 --- a/apps/api/src/routes/api/v1/applications/types.ts +++ b/apps/api/src/routes/api/v1/applications/types.ts @@ -19,6 +19,7 @@ export interface SaveApplication extends OnlyId { denoMainFile: string, denoOptions: string, baseImage: string, + gitCommitHash: string, baseBuildImage: string, deploymentType: string, baseDatabaseBranch: string, diff --git a/apps/ui/src/routes/applications/[id]/index.svelte b/apps/ui/src/routes/applications/[id]/index.svelte index 483a8050d..e484f5c98 100644 --- a/apps/ui/src/routes/applications/[id]/index.svelte +++ b/apps/ui/src/routes/applications/[id]/index.svelte @@ -515,6 +515,23 @@ > {/if} +
+ + {#if isDisabled} + + {:else} + + {/if} +
{#if isDisabled || application.settings.isPublicRepository} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bde46822..494c9b59f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -268,7 +268,6 @@ packages: engines: {node: '>= 12.11'} peerDependencies: bree: '>=9.0.0' - tsconfig-paths: '>= 4' dependencies: bree: 9.1.2 ts-node: 10.8.2_wup25etrarvlqkprac7h35hj7u @@ -322,6 +321,23 @@ packages: - supports-color dev: true + /@eslint/eslintrc/1.3.3: + resolution: {integrity: sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + dependencies: + ajv: 6.12.6 + debug: 4.3.4 + espree: 9.4.0 + globals: 13.15.0 + ignore: 5.2.0 + import-fresh: 3.3.0 + js-yaml: 4.1.0 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + dev: true + /@fastify/accept-negotiator/1.0.0: resolution: {integrity: sha512-4R/N2KfYeld7A5LGkai+iUFMahXcxxYbDp+XS2B1yuL3cdmZLJ9TlCnNzT3q5xFTqsYm0GPpinLUwfSwjcVjyA==} engines: {node: '>=14'} @@ -2982,6 +2998,16 @@ packages: eslint-visitor-keys: 2.1.0 dev: true + /eslint-utils/3.0.0_eslint@8.25.0: + resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} + engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} + peerDependencies: + eslint: '>=5' + dependencies: + eslint: 8.25.0 + eslint-visitor-keys: 2.1.0 + dev: true + /eslint-visitor-keys/2.1.0: resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==} engines: {node: '>=10'} @@ -3040,6 +3066,53 @@ packages: - supports-color dev: true + /eslint/8.25.0: + resolution: {integrity: sha512-DVlJOZ4Pn50zcKW5bYH7GQK/9MsoQG2d5eDH0ebEkE8PbgzTTmtt/VTH9GGJ4BfeZCpBLqFfvsjX35UacUL83A==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + hasBin: true + dependencies: + '@eslint/eslintrc': 1.3.3 + '@humanwhocodes/config-array': 0.10.7 + '@humanwhocodes/module-importer': 1.0.1 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.3 + debug: 4.3.4 + doctrine: 3.0.0 + escape-string-regexp: 4.0.0 + eslint-scope: 7.1.1 + eslint-utils: 3.0.0_eslint@8.25.0 + eslint-visitor-keys: 3.3.0 + espree: 9.4.0 + esquery: 1.4.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 6.0.1 + find-up: 5.0.0 + glob-parent: 6.0.2 + globals: 13.15.0 + globby: 11.1.0 + grapheme-splitter: 1.0.4 + ignore: 5.2.0 + import-fresh: 3.3.0 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + js-sdsl: 4.1.5 + js-yaml: 4.1.0 + json-stable-stringify-without-jsonify: 1.0.1 + levn: 0.4.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.1 + regexpp: 3.2.0 + strip-ansi: 6.0.1 + strip-json-comments: 3.1.1 + text-table: 0.2.0 + transitivePeerDependencies: + - supports-color + dev: true + /espree/9.4.0: resolution: {integrity: sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -5958,8 +6031,6 @@ packages: resolution: {integrity: sha512-AhwtHCKMtR71JgeYDaswmZXhPcW9iuI9Sp2LvZPo9upDZ7231ZJ7eA9RaURbhpXGVlrjX4cFNlB4ieTetEb7hQ==} engines: {node: '>=12.13.0'} hasBin: true - peerDependencies: - postcss: ^8.0.9 dependencies: arg: 5.0.2 chokidar: 3.5.3