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
|
FROM ekidd/rust-musl-builder:stable as backend
|
||||||
|
|
||||||
# create new cargo project
|
# 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
|
RUN USER=rust cargo new --lib time-cache
|
||||||
# copy build config
|
# copy build config
|
||||||
COPY --chown=rust ./backend/Cargo.lock ./gitache/Cargo.lock
|
COPY --chown=rust ./backend/Cargo.lock ./yagcdn/Cargo.lock
|
||||||
COPY --chown=rust ./backend/Cargo.toml ./gitache/Cargo.toml
|
COPY --chown=rust ./backend/Cargo.toml ./yagcdn/Cargo.toml
|
||||||
COPY --chown=rust ./time-cache/Cargo.toml ./time-cache/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
|
# build to cache dependencies
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
# delete build cache to prevent caching issues later on
|
# 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-*
|
RUN rm -r ./target/x86_64-unknown-linux-musl/release/.fingerprint/time-cache-*
|
||||||
|
|
||||||
COPY ./backend/static ./static
|
COPY ./backend/static ./static
|
||||||
@ -49,9 +49,9 @@ COPY --from=linuxkit/ca-certificates:v0.7 / /
|
|||||||
COPY --from=user_builder /etc/passwd /etc/passwd
|
COPY --from=user_builder /etc/passwd /etc/passwd
|
||||||
USER dummy
|
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/index.html /public/index.html
|
||||||
COPY --from=frontend /output/scripts /public/scripts
|
COPY --from=frontend /output/scripts /public/scripts
|
||||||
COPY --from=frontend /output/assets /public/assets
|
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
|
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
|
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.
|
cache headers, so the service can be put behind a CDN like Cloudflare.
|
||||||
@ -20,7 +20,7 @@ exposing port `8080`.
|
|||||||
|
|
||||||
## API Limits
|
## 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
|
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
|
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.
|
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_ZONE_IDENT` | `--cf-zone` | Cloudflare Zone identifier |
|
||||||
| `CF_AUTH_USER` | `--cf-auth-user` | CF API User (`X-Auth-Email`) |
|
| `CF_AUTH_USER` | `--cf-auth-user` | CF API User (`X-Auth-Email`) |
|
||||||
| `CF_AUTH_KEY` | `--cf-auth-key` | CF API Key (`X-Auth-Key`) |
|
| `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)",
|
"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]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.1.25"
|
version = "0.1.25"
|
||||||
@ -1966,6 +1946,26 @@ dependencies = [
|
|||||||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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]
|
[metadata]
|
||||||
"checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453"
|
"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"
|
"checksum actix-connect 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d161322a26e6b76d6598f48654afbdcfee644c900d4368e9962ec68abd0713b"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gitache"
|
name = "yagcdn"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||||
edition = "2018"
|
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 REDIRECT_AGE: Duration = Duration::from_secs(5 * 60);
|
||||||
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||||
lazy_static! {
|
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 OPT: Opt = Opt::from_args();
|
||||||
pub(crate) static ref GITHUB_AUTH_QUERY: String = Github::auth_query().unwrap_or_default();
|
pub(crate) static ref GITHUB_AUTH_QUERY: String = Github::auth_query().unwrap_or_default();
|
||||||
pub(crate) static ref CF_ZONE_IDENT: String = OPT
|
pub(crate) static ref CF_ZONE_IDENT: String = OPT
|
||||||
@ -27,8 +27,8 @@ lazy_static! {
|
|||||||
pub(crate) static ref HOSTNAME: String = OPT
|
pub(crate) static ref HOSTNAME: String = OPT
|
||||||
.hostname
|
.hostname
|
||||||
.clone()
|
.clone()
|
||||||
.or_else(|| load_env_var("GITACHE_HOSTNAME"))
|
.or_else(|| load_env_var("YAGCDN_HOSTNAME"))
|
||||||
.unwrap_or_else(|| "gitcdn.tk".to_string());
|
.unwrap_or_else(|| "yagcdn.tk".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn load_env_var(key: &str) -> Option<String> {
|
pub(crate) fn load_env_var(key: &str) -> Option<String> {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
version: '2'
|
version: '2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
gitache:
|
yagcdn:
|
||||||
build: ./
|
image: vbrandl/yagcdn:latest
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
- CF_ZONE_IDENT=${CF_ZONE_IDENT}
|
- CF_ZONE_IDENT=${CF_ZONE_IDENT}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
js="gitcdn.js"
|
js="yagcdn.js"
|
||||||
min="gitcdn.min.js"
|
min="yagcdn.min.js"
|
||||||
outdir="./output/"
|
outdir="./output/"
|
||||||
scriptdir="${outdir}scripts/"
|
scriptdir="${outdir}scripts/"
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ sha1() {
|
|||||||
|
|
||||||
rename_with_hash() {
|
rename_with_hash() {
|
||||||
sha1=${1}
|
sha1=${1}
|
||||||
cp ${min} "${scriptdir}/gitcdn-${sha1}.min.js"
|
cp ${min} "${scriptdir}/yagcdn-${sha1}.min.js"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_index() {
|
create_index() {
|
||||||
|
@ -3,7 +3,7 @@ module Data exposing (Provider(..), Url, hostname, pathSeparator, toUrl)
|
|||||||
|
|
||||||
hostname : String
|
hostname : String
|
||||||
hostname =
|
hostname =
|
||||||
"https://gitcdn.tk/"
|
"https://yagcdn.tk/"
|
||||||
|
|
||||||
|
|
||||||
type Provider
|
type Provider
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
<body>
|
<body>
|
||||||
<section>
|
<section>
|
||||||
<header>
|
<header>
|
||||||
<h1>GitCDN</h1>
|
<h1>YaGCDN</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<div id="elm-${SHA1}"></div>
|
<div id="elm-${SHA1}"></div>
|
||||||
<script src="./scripts/gitcdn-${SHA1}.min.js">
|
<script src="./scripts/yagcdn-${SHA1}.min.js">
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var app = Elm.Main.init({ node: document.getElementById("elm-${SHA1}") });
|
var app = Elm.Main.init({ node: document.getElementById("elm-${SHA1}") });
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<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>
|
||||||
<li>
|
<li>
|
||||||
<small><a href="https://opensource.org/licenses/MIT">MIT License</a></small>
|
<small><a href="https://opensource.org/licenses/MIT">MIT License</a></small>
|
||||||
|
Loading…
Reference in New Issue
Block a user