forked from chrisguida/gitea-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* convert to run on x86 * make build process multi arch compatible * optimize build layer * update Makefile and README to best practices * Update README.md Co-authored-by: Chris Guida <[email protected]> * update readme * update readme to link to packaging docs * rename folders/file * convert health checks to js * update copy and deps version Co-authored-by: Chris Guida <[email protected]>
- Loading branch information
1 parent
369005e
commit d166533
Showing
15 changed files
with
115 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ gitea.s9pk | |
image.tar | ||
scripts/embassy.js | ||
.vscode | ||
docker-images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
FROM gitea/gitea:1.16.9 | ||
|
||
RUN apk update | ||
RUN apk add --no-cache tini curl | ||
|
||
RUN wget https://github.com/mikefarah/yq/releases/download/v4.27.2/yq_linux_arm.tar.gz -O - |\ | ||
tar xz && mv yq_linux_arm /usr/bin/yq | ||
RUN apk add --no-cache tini curl yq --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community | ||
|
||
ADD ./docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh | ||
RUN chmod a+x /usr/local/bin/docker_entrypoint.sh | ||
ADD ./check-web.sh /usr/local/bin/check-web.sh | ||
RUN chmod +x /usr/local/bin/check-web.sh | ||
ADD ./check-user-signups-off.sh /usr/local/bin/check-user-signups-off.sh | ||
RUN chmod +x /usr/local/bin/check-user-signups-off.sh | ||
RUN chmod a+x /usr/local/bin/docker_entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
ASSETS := $(shell yq e '.assets.[].src' manifest.yaml) | ||
VERSION := $(shell yq e ".version" manifest.yaml) | ||
S9PK_PATH=$(shell find . -name gitea.s9pk -print) | ||
PKG_VERSION := $(shell yq e ".version" manifest.yaml) | ||
PKG_ID := $(shell yq e ".id" manifest.yaml) | ||
TS_FILES := $(shell find . -name \*.ts ) | ||
|
||
# delete the target of a rule if it has changed and its recipe exits with a nonzero exit status | ||
.DELETE_ON_ERROR: | ||
|
||
all: verify | ||
|
||
install: gitea.s9pk | ||
embassy-cli package install gitea.s9pk | ||
# assumes /etc/embassy/config.yaml exists on local system with `host: "http://embassy-server-name.local"` configured | ||
install: $(PKG_ID).s9pk | ||
embassy-cli package install $(PKG_ID).s9pk | ||
|
||
verify: gitea.s9pk $(S9PK_PATH) | ||
embassy-sdk verify s9pk $(S9PK_PATH) | ||
verify: $(PKG_ID).s9pk | ||
embassy-sdk verify s9pk $(PKG_ID).s9pk | ||
|
||
clean: | ||
rm -rf docker-images | ||
rm -f $(PKG_ID).s9pk | ||
rm -f image.tar | ||
rm -f gitea.s9pk | ||
rm -f scripts/*.js | ||
|
||
gitea.s9pk: manifest.yaml image.tar instructions.md scripts/embassy.js | ||
$(PKG_ID).s9pk: manifest.yaml instructions.md scripts/embassy.js gitea/LICENSE docker-images/aarch64.tar docker-images/x86_64.tar | ||
if ! [ -z "$(ARCH)" ]; then cp docker-images/$(ARCH).tar image.tar; fi | ||
embassy-sdk pack | ||
|
||
image.tar: Dockerfile docker_entrypoint.sh check-web.sh | ||
DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --tag start9/gitea/main:$(VERSION) --platform=linux/arm64 -o type=docker,dest=image.tar . | ||
docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh | ||
mkdir -p docker-images | ||
DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar . | ||
|
||
docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh | ||
mkdir -p docker-images | ||
DOCKER_CLI_EXPERIMENTAL=enabled docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar . | ||
|
||
scripts/embassy.js: $(TS_FILES) | ||
deno bundle scripts/embassy.ts scripts/embassy.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from "https://deno.land/x/[email protected].2/mod.ts"; | ||
export * from "https://deno.land/x/[email protected].4/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { properties } from "./services/properties.ts"; | ||
export { setConfig } from "./services/setConfig.ts"; | ||
export { getConfig } from "./services/getConfig.ts"; | ||
export { migration } from "./services/migrations.ts"; | ||
export { properties } from "./procedures/properties.ts"; | ||
export { setConfig } from "./procedures/setConfig.ts"; | ||
export { getConfig } from "./procedures/getConfig.ts"; | ||
export { migration } from "./procedures/migrations.ts"; | ||
export { health } from "./procedures/healthChecks.ts"; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { types as T, matches, util } from "../deps.ts"; | ||
import { getConfig } from "./getConfig.ts"; | ||
|
||
export const health: T.ExpectedExports.health = { | ||
// deno-lint-ignore require-await | ||
async "web"(effects, duration) { | ||
return healthWeb(effects, duration); | ||
}, | ||
// deno-lint-ignore require-await | ||
async "user-signups-off"(effects, duration) { | ||
return healthSignups(effects, duration); | ||
}, | ||
}; | ||
|
||
const healthWeb: T.ExpectedExports.health[""] = async (effects, duration) => { | ||
await guardDurationAboveMinimum({ duration, minimumTime: 5000 }); | ||
|
||
return await effects.fetch("http://gitea.embassy:3000") | ||
.then((_) => ok) | ||
.catch((e) => { | ||
effects.error(`${e}`) | ||
return error(`The Gitea UI is unreachable`) | ||
}); | ||
}; | ||
|
||
const healthSignups: T.ExpectedExports.health[""] = async (effects, duration) => { | ||
await guardDurationAboveMinimum({ duration, minimumTime: 5000 }); | ||
const config = (util.unwrapResultType(await getConfig(effects))).config! | ||
if (!matchRegistration.test(config)) { | ||
throw `Could not find "disable-registration" key in config: ${matchRegistration.errorMessage(config)}` | ||
} | ||
if (!config['disable-registration']) { | ||
return error("For security purposes, user account registration should be disabled when not in use. You can disable registration in Config settings.") | ||
} | ||
return ok | ||
} | ||
|
||
// *** HELPER FUNCTIONS *** // | ||
|
||
const { shape, boolean } = matches | ||
const matchRegistration = shape({ | ||
'disable-registration': boolean | ||
}) | ||
|
||
// Ensure the starting duration is past a minimum | ||
const guardDurationAboveMinimum = ( | ||
input: { duration: number; minimumTime: number }, | ||
) => | ||
(input.duration <= input.minimumTime) | ||
? Promise.reject(errorCode(60, "Starting")) | ||
: null; | ||
|
||
const errorCode = (code: number, error: string) => ({ | ||
"error-code": [code, error] as const, | ||
}); | ||
const error = (error: string) => ({ error }); | ||
const ok = { result: null }; |
2 changes: 1 addition & 1 deletion
2
scripts/services/migrations.ts → scripts/procedures/migrations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { compat, types as T } from "../deps.ts"; | ||
|
||
export const migration: T.ExpectedExports.migration = compat.migrations | ||
.fromMapping( {}, "1.16.9" ); | ||
.fromMapping( {}, "1.16.9.1" ); |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
scripts/services/setConfig.ts → scripts/procedures/setConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.