Skip to content

Commit

Permalink
Switch to go-gitea docker image (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem committed Apr 12, 2024
1 parent 8fa6917 commit 9215e6e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 32 deletions.
1 change: 0 additions & 1 deletion docker-compose.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
restart: always

gitea:
image: ghcr.io/kitspace/gitea${GITEA_DEPLOY_IMAGE_TAG}
command: /usr/bin/entrypoint
restart: always
ports:
Expand Down
5 changes: 0 additions & 5 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ services:
command: /bin/sh --verbose -c 'yarn install && yarn dev'

gitea:
build:
context: gitea
dockerfile: Dockerfile.gitea.dev
ports:
- '3333:3000'
- '2222:22'
volumes:
- ./gitea:/go/src/code.gitea.io/gitea
# => gitea/docker/root/usr/bin/kitspace_dev_entrypoint
entrypoint: ['/usr/bin/kitspace_dev_entrypoint']

postgres:
ports:
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
- gitea

gitea:
image: gitea/gitea:1.21
environment:
- ROOT_URL=${KITSPACE_SCHEME}://gitea.${KITSPACE_DOMAIN}${KITSPACE_EXTERNAL_PORT}/
- USER_UID=1000
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Cypress.Commands.add('importRepo', (remoteUrl, repoName, user) => {
method: 'GET',
failOnStatusCode: false,
})
.then(response => response.body.empty !== false),
.then(response => response.body.empty === false),
{ timeout: 60_000, interval: 1000 },
)
})
Expand Down
21 changes: 2 additions & 19 deletions processor/src/giteaDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,12 @@ export async function waitForNonEmpty(repoId: string): Promise<void> {
*/
export async function waitForRepoMigration(repoId: string): Promise<void> {
const rows =
await sql`SELECT EXISTS (SELECT 1 FROM task WHERE repo_id=${repoId} AND
type=${TaskType.Migration} AND status=${MigrationStatus.Done})`
await sql`SELECT EXISTS (SELECT 1 FROM mirror WHERE repo_id=${repoId})`

if (rows[0]?.exists) {
return
}

await once(
'update:task',
row =>
row.repo_id === repoId &&
row.type === TaskType.Migration &&
row.status === MigrationStatus.Done &&
row.default_branch !== '',
)
await once('update:mirror', row => row.repo_id === repoId)
}

/**
Expand Down Expand Up @@ -121,18 +112,10 @@ export interface RepoInfo {
description: string
}

enum TaskType {
Migration = 0,
}

export enum Operation {
// https://github.com/porsager/postgres#operation-------schema--table--primary_key
Insert = 'insert',
Update = 'update',
Delete = 'delete',
All = '*',
}

enum MigrationStatus {
Done = 4,
}
3 changes: 2 additions & 1 deletion processor/src/healthChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export async function checkPartInfoHealth() {
},
})
if (res.status !== 200) {
throw new Error(`${endpoint} health check failed with status ${res.status}`)
log.error(`${endpoint} health check failed with status ${res.status}`)
// throw new Error(`${endpoint} health check failed with status ${res.status}`)
} else {
log.debug(`${endpoint} health check passed`)
}
Expand Down
10 changes: 5 additions & 5 deletions scripts/importBoardsTxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ async function mirrorRepo(
let message = 'Unknown error'
try {
message = (await response.json()).message
} catch (e) {}
} catch (e) { }
throw new Error(
`Failed to mirror ${remoteRepo} to ${user.username}/${repoName}: ${response.status}: ${message}`,
)
Expand All @@ -187,12 +187,12 @@ async function getAllGithubReposDescriptions(
const query = `
query {
${reposOwnerAndName.map(
([owner, name], index) => `
([owner, name], index) => `
r${index}: repository(owner: "${owner}", name: "${name}") {
fullName: nameWithOwner
description
}`,
)}
)}
}
`
const { data: reposInfo }: GitHubRepoInfoGQLResponse = await fetch(
Expand Down Expand Up @@ -302,15 +302,15 @@ async function generateGiteaAdminToken() {
}

const giteaAdminTokenCommand = await exec(
`bash -c "docker exec --user git ${getGiteaContainerCommand.output} /bin/sh -c 'gitea admin user generate-access-token --username ${adminUsername} --raw'"`,
`bash -c "docker exec --user git ${getGiteaContainerCommand.output} /bin/sh -c 'gitea admin user generate-access-token --username ${adminUsername} --raw --scopes write:admin,write:repository,read:admin,read:user'"`,
{ output: OutputMode.Capture },
)

if (!giteaAdminTokenCommand.status.success) {
throw new Error('Failed to create gitea admin token')
}

return giteaAdminTokenCommand.output
return giteaAdminTokenCommand.output.split('\n').at(-1)
}

type GithubReposDescriptionsMap = Map<string, string>
Expand Down

0 comments on commit 9215e6e

Please sign in to comment.