This commit is contained in:
parent
99eb44d618
commit
3f5b118ac5
14
Dockerfile
14
Dockerfile
@ -17,18 +17,18 @@ RUN ./build.sh
|
||||
FROM ekidd/rust-musl-builder:stable as backend
|
||||
|
||||
# create new cargo project
|
||||
RUN USER=rust cargo new --bin gitache
|
||||
RUN USER=rust cargo new --bin yagcdn
|
||||
RUN USER=rust cargo new --lib time-cache
|
||||
# copy build config
|
||||
COPY --chown=rust ./backend/Cargo.lock ./gitache/Cargo.lock
|
||||
COPY --chown=rust ./backend/Cargo.toml ./gitache/Cargo.toml
|
||||
COPY --chown=rust ./backend/Cargo.lock ./yagcdn/Cargo.lock
|
||||
COPY --chown=rust ./backend/Cargo.toml ./yagcdn/Cargo.toml
|
||||
COPY --chown=rust ./time-cache/Cargo.toml ./time-cache/Cargo.toml
|
||||
|
||||
WORKDIR /home/rust/src/gitache
|
||||
WORKDIR /home/rust/src/yagcdn
|
||||
# build to cache dependencies
|
||||
RUN cargo build --release
|
||||
# delete build cache to prevent caching issues later on
|
||||
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/gitache-*
|
||||
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/yagcdn*
|
||||
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/time-cache-*
|
||||
|
||||
COPY ./backend/static ./static
|
||||
@ -49,9 +49,9 @@ COPY --from=linuxkit/ca-certificates:v0.7 / /
|
||||
COPY --from=user_builder /etc/passwd /etc/passwd
|
||||
USER dummy
|
||||
|
||||
COPY --from=backend /home/rust/src/gitache/target/x86_64-unknown-linux-musl/release/gitache /
|
||||
COPY --from=backend /home/rust/src/yagcdn/target/x86_64-unknown-linux-musl/release/yagcdn /
|
||||
COPY --from=frontend /output/index.html /public/index.html
|
||||
COPY --from=frontend /output/scripts /public/scripts
|
||||
COPY --from=frontend /output/assets /public/assets
|
||||
|
||||
ENTRYPOINT ["/gitache"]
|
||||
ENTRYPOINT ["/yagcdn"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Gitache
|
||||
# YaGCDN
|
||||
|
||||
Gitache is a web service that serves raw files from GitHub, GitLab and Bitbucket
|
||||
YaGCDN is a web service that serves raw files from GitHub, GitLab and Bitbucket
|
||||
with the proper `Content-Type` headers. Requests to a branch will be redirected
|
||||
to the branches `HEAD`. Requests to a specific commit will also set long time
|
||||
cache headers, so the service can be put behind a CDN like Cloudflare.
|
||||
@ -20,7 +20,7 @@ exposing port `8080`.
|
||||
|
||||
## API Limits
|
||||
|
||||
To get the `HEAD` of a requested branch, Gitache sends a request to the
|
||||
To get the `HEAD` of a requested branch, YaGCDN sends a request to the
|
||||
requested service's API. To prevent running into rate limiting issues with the
|
||||
GitHub API, an OAuth2 App should be created and the client ID and secret can be
|
||||
set via the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` environment variables.
|
||||
@ -34,4 +34,4 @@ set via the `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` environment variables.
|
||||
| `CF_ZONE_IDENT` | `--cf-zone` | Cloudflare Zone identifier |
|
||||
| `CF_AUTH_USER` | `--cf-auth-user` | CF API User (`X-Auth-Email`) |
|
||||
| `CF_AUTH_KEY` | `--cf-auth-key` | CF API Key (`X-Auth-Key`) |
|
||||
| `HOSTNAME` | `--hostname` | Hostname (default: `gitcdn.tk`) |
|
||||
| `YAGCDN_HOSTNAME` | `--hostname` | Hostname (default: `yagcdn.tk`) |
|
40
backend/Cargo.lock
generated
40
backend/Cargo.lock
generated
@ -642,26 +642,6 @@ dependencies = [
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitache"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-files 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time-cache 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.1.25"
|
||||
@ -1966,6 +1946,26 @@ dependencies = [
|
||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yagcdn"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"actix-files 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"actix-web 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"awc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time-cache 0.1.0",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453"
|
||||
"checksum actix-connect 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d161322a26e6b76d6598f48654afbdcfee644c900d4368e9962ec68abd0713b"
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "gitache"
|
||||
name = "yagcdn"
|
||||
version = "0.1.0"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
|
@ -6,7 +6,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub(crate) const REDIRECT_AGE: Duration = Duration::from_secs(5 * 60);
|
||||
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||
lazy_static! {
|
||||
pub(crate) static ref USER_AGENT: String = format!("gitache/{}", VERSION);
|
||||
pub(crate) static ref USER_AGENT: String = format!("yagcdn/{}", VERSION);
|
||||
pub(crate) static ref OPT: Opt = Opt::from_args();
|
||||
pub(crate) static ref GITHUB_AUTH_QUERY: String = Github::auth_query().unwrap_or_default();
|
||||
pub(crate) static ref CF_ZONE_IDENT: String = OPT
|
||||
@ -27,8 +27,8 @@ lazy_static! {
|
||||
pub(crate) static ref HOSTNAME: String = OPT
|
||||
.hostname
|
||||
.clone()
|
||||
.or_else(|| load_env_var("GITACHE_HOSTNAME"))
|
||||
.unwrap_or_else(|| "gitcdn.tk".to_string());
|
||||
.or_else(|| load_env_var("YAGCDN_HOSTNAME"))
|
||||
.unwrap_or_else(|| "yagcdn.tk".to_string());
|
||||
}
|
||||
|
||||
pub(crate) fn load_env_var(key: &str) -> Option<String> {
|
||||
|
@ -1,8 +1,8 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
gitache:
|
||||
build: ./
|
||||
yagcdn:
|
||||
image: vbrandl/yagcdn:latest
|
||||
restart: always
|
||||
environment:
|
||||
- CF_ZONE_IDENT=${CF_ZONE_IDENT}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
js="gitcdn.js"
|
||||
min="gitcdn.min.js"
|
||||
js="yagcdn.js"
|
||||
min="yagcdn.min.js"
|
||||
outdir="./output/"
|
||||
scriptdir="${outdir}scripts/"
|
||||
|
||||
@ -24,7 +24,7 @@ sha1() {
|
||||
|
||||
rename_with_hash() {
|
||||
sha1=${1}
|
||||
cp ${min} "${scriptdir}/gitcdn-${sha1}.min.js"
|
||||
cp ${min} "${scriptdir}/yagcdn-${sha1}.min.js"
|
||||
}
|
||||
|
||||
create_index() {
|
||||
|
@ -3,7 +3,7 @@ module Data exposing (Provider(..), Url, hostname, pathSeparator, toUrl)
|
||||
|
||||
hostname : String
|
||||
hostname =
|
||||
"https://gitcdn.tk/"
|
||||
"https://yagcdn.tk/"
|
||||
|
||||
|
||||
type Provider
|
||||
|
@ -11,12 +11,12 @@
|
||||
<body>
|
||||
<section>
|
||||
<header>
|
||||
<h1>GitCDN</h1>
|
||||
<h1>YaGCDN</h1>
|
||||
</header>
|
||||
|
||||
<article>
|
||||
<div id="elm-${SHA1}"></div>
|
||||
<script src="./scripts/gitcdn-${SHA1}.min.js">
|
||||
<script src="./scripts/yagcdn-${SHA1}.min.js">
|
||||
</script>
|
||||
<script>
|
||||
var app = Elm.Main.init({ node: document.getElementById("elm-${SHA1}") });
|
||||
@ -45,7 +45,7 @@
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<small><a href="https://git.vbrandl.net/vbrandl/gitache">Repository</a></small>
|
||||
<small><a href="https://github.com/vbrandl/yagcdn">Repository</a></small>
|
||||
</li>
|
||||
<li>
|
||||
<small><a href="https://opensource.org/licenses/MIT">MIT License</a></small>
|
||||
|
Loading…
Reference in New Issue
Block a user