Compare commits
No commits in common. "master" and "0.0.1" have entirely different histories.
13
Caddyfile
13
Caddyfile
@ -1,18 +1,9 @@
|
||||
# caddy reload --config /etc/caddy/Caddyfile
|
||||
{
|
||||
order gitea before file_server
|
||||
}
|
||||
:3003
|
||||
gitea {
|
||||
token {$GITEA_ACCESS_TOKEN} # Settings > Applications > Generate Token
|
||||
server {$GITEA_HOST} # https://yourgitea.yourdomain.com
|
||||
token {$GITEA_ACCESS_TOKEN} # Settings > Applications > Generate Token
|
||||
server {$GITEA_HOST} # https://yourgitea.yourdomain.com
|
||||
domain {$PAGES_DOMAIN} # pages.yourdomain.com
|
||||
}
|
||||
|
||||
@js {
|
||||
path *.js
|
||||
}
|
||||
|
||||
header @js {
|
||||
Content-Type text/javascript # https://gitea.djmil.dev/djmil/gitea-pages/issues/3
|
||||
}
|
||||
|
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM caddy:2.8.4-builder-alpine AS builder
|
||||
|
||||
COPY pkg/gitea/* /module/gitea-pages/pkg/gitea/
|
||||
COPY gitea-pages.go go.mod go.sum /module/gitea-pages/
|
||||
|
||||
RUN xcaddy build \
|
||||
--with gitea.djmil.dev/goland/gitea-pages \
|
||||
--replace gitea.djmil.dev/goland/gitea-pages=/module/gitea-pages \
|
||||
--replace gitea.djmil.dev/goland/gitea-pages/pkg/gitea=/module/gitea-pages/pkg/gitea
|
||||
|
||||
FROM caddy:2.8.4
|
||||
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
|
||||
EXPOSE 3003/tcp
|
55
README.md
55
README.md
@ -1,6 +1,6 @@
|
||||
# gitea-pages
|
||||
|
||||
Fork of the [caddy-gitea](https://github.com/42wim/caddy-gitea) project: [Gitea](https://gitea.io) plugin for [Caddy v2](https://github.com/caddyserver/caddy). List of [alternatives](https://docs.gitea.com/awesome#web-hosting).
|
||||
Fork of the [caddy-gitea](https://github.com/42wim/caddy-gitea) project: [Gitea](https://gitea.io) plugin for [Caddy v2](https://github.com/caddyserver/caddy).
|
||||
|
||||
The project aims to have Github Pages in Gitea. For doing so it relies on a wildcard CNAME DNS entry to the gitea host.
|
||||
|
||||
@ -8,16 +8,16 @@ For now markdown files (with `.md` extension) will also be automatically generat
|
||||
|
||||
<!-- TOC -->
|
||||
|
||||
- [Getting started](#getting-started)
|
||||
- [Caddy config](#caddy-config)
|
||||
- [DNS config](#dns-config)
|
||||
- [Gitea config](#gitea-config)
|
||||
- [gitea-pages repo](#gitea-pages-repo)
|
||||
- [any repo with configurable allowed branch/tag/commits](#any-repo-with-configurable-allowed-branchtagcommits)
|
||||
- [any repo with all branches/tags/commits exposed](#any-repo-with-all-branchestagscommits-exposed)
|
||||
- [Building caddy with plugin](#building-caddy)
|
||||
- [Build locally](#build-with-locally-cloned-plugin-sources)
|
||||
- [Integration with Gitea](#integration-with-gitea)
|
||||
- [caddy-gitea](#caddy-gitea)
|
||||
- [Getting started](#getting-started)
|
||||
- [Caddy config](#caddy-config)
|
||||
- [DNS config](#dns-config)
|
||||
- [Gitea config](#gitea-config)
|
||||
- [gitea-pages repo](#gitea-pages-repo)
|
||||
- [any repo with configurable allowed branch/tag/commits](#any-repo-with-configurable-allowed-branchtagcommits)
|
||||
- [any repo with all branches/tags/commits exposed](#any-repo-with-all-branchestagscommits-exposed)
|
||||
- [Building caddy](#building-caddy)
|
||||
- [Integration & deployment](#Integration with Gitea)
|
||||
|
||||
<!-- /TOC -->
|
||||
|
||||
@ -112,38 +112,15 @@ e.g. we'll use the `yourrepo` repo in the `yourorg` org and there is a `file.htm
|
||||
## Building caddy
|
||||
|
||||
As this is a 3rd party plugin you'll need to build caddy (or use the binaries).
|
||||
To build with this plugin you'll need to have `Golang v1.19` installed. Basic idea:
|
||||
To build with this plugin you'll need to have go1.19 installed.
|
||||
|
||||
```bash
|
||||
# 1 install xcaddy in ~/go/bin
|
||||
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
||||
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest #this will install xcaddy in ~/go/bin
|
||||
|
||||
# 2 build caddy binary with the latest plugin version
|
||||
xcaddy build \
|
||||
--with gitea.djmil.dev/djmil/gitea-pages
|
||||
```
|
||||
|
||||
### Build with locally cloned plugin sources
|
||||
|
||||
Also Docker builder image can be used to build caddy alongside locally cloned git repo of a plugin:
|
||||
|
||||
```Dockerfile
|
||||
FROM caddy:2.8.4-builder-alpine AS builder
|
||||
|
||||
COPY gitea-pages.go go.mod go.sum /module/gitea-pages/
|
||||
COPY pkg/gitea/* /module/gitea-pages/pkg/gitea/
|
||||
|
||||
RUN xcaddy build \
|
||||
--with gitea.djmil.dev/djmil/gitea-pages \
|
||||
--replace gitea.djmil.dev/djmil/gitea-pages=/module/gitea-pages \
|
||||
--replace gitea.djmil.dev/djmil/gitea-pages/pkg/gitea=/module/gitea-pages/pkg/gitea
|
||||
|
||||
FROM caddy:2.8.4
|
||||
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
|
||||
EXPOSE 3003/tcp
|
||||
--with gitea.djmil.dev/goland/gitea-pages \
|
||||
--replace gitea.djmil.dev/goland/gitea-pages=/module/gitea-pages \
|
||||
--replace gitea.djmil.dev/goland/gitea-pages/pkg/gitea=/module/gitea-pages/pkg/gitea
|
||||
```
|
||||
|
||||
## Integration with Gitea
|
||||
|
@ -1,98 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
usage="$(basename "$0") [--release=<version>] [--publish] [-h]
|
||||
|
||||
Compile Caddy server with gitea-pages plugin inside docker container. Buy
|
||||
default local sources will be used for build.
|
||||
|
||||
You can also compile known release. The given release tag will be fetched from
|
||||
the project git repo at https://gitea.djmil.dev/djmil/gitea-pages.
|
||||
|
||||
Optionally, the script can be used to publish resulting docker image to the
|
||||
https://hub.docker.com/repository/docker/djmil/gitea-pages.
|
||||
|
||||
Params for the short options version shall be separated by space. For the long
|
||||
options - equal sign shall be used. Example:
|
||||
--release=0.1.0
|
||||
-r 0.0.1
|
||||
|
||||
Where:
|
||||
-l | --local
|
||||
Build local sources. Default behaviour.
|
||||
|
||||
-r | --release <version>
|
||||
A major.minor.patch tag of the known release to build.
|
||||
|
||||
-p | --publish
|
||||
Publish resulting image to the docker hub. Typically shall be used
|
||||
together with --release option.
|
||||
|
||||
-h | --help
|
||||
Show this message and exit.
|
||||
"
|
||||
|
||||
R="\033[0;31m" # RED
|
||||
G="\033[0;32m" # GREEN
|
||||
Y="\033[0;33m" # YELLOW
|
||||
B="\033[1;34m" # BLUE
|
||||
NC="\033[0;0m" # NO COLOR
|
||||
|
||||
###############################################################################
|
||||
# Parse long and short options, source: https://stackoverflow.com/a/28466267
|
||||
|
||||
# Defaults
|
||||
tag='local'
|
||||
publish=false
|
||||
|
||||
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
|
||||
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }
|
||||
|
||||
while getopts r:lph-: OPT; do # allow -a, -b with arg, -c, and -- "with arg"
|
||||
# support long options: https://stackoverflow.com/a/28466267/519360
|
||||
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
|
||||
OPT="${OPTARG%%=*}" # extract long option name
|
||||
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
|
||||
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
|
||||
fi
|
||||
case "$OPT" in
|
||||
l | local ) tag='local' ;;
|
||||
r | release ) needs_arg; tag="$OPTARG" ;;
|
||||
p | publish ) publish=true ;;
|
||||
h | help ) echo "$usage" >&2; exit 0 ;;
|
||||
\? ) exit 2 ;; # bad short option (error reported via getopts)
|
||||
* ) die "Illegal option --$OPT" ;; # bad long option
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1)) # remove parsed options and args from $@ list
|
||||
###############################################################################
|
||||
|
||||
|
||||
if [ $tag = 'local' ]; then
|
||||
echo -e "${Y} -->> Local dev-mode build: compile local sources${NC}";
|
||||
|
||||
docker build \
|
||||
--file docker/local.dockerfile \
|
||||
--tag djmil/gitea-pages:local \
|
||||
.
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
echo -e "${Y} -->> Building release ${B}'$tag'${NC}";
|
||||
|
||||
docker build \
|
||||
--file docker/release.dockerfile \
|
||||
--build-arg RELEASE=$tag \
|
||||
--tag djmil/gitea-pages:$tag \
|
||||
.
|
||||
|
||||
|
||||
if $publish; then
|
||||
echo -e "${Y} -->> Publishing to the dockerhub";
|
||||
|
||||
docker login --username djmil #--password-stdin
|
||||
|
||||
docker push djmil/gitea-pages:$tag
|
||||
fi
|
@ -1,24 +0,0 @@
|
||||
FROM caddy:2.8.4-builder-alpine AS builder
|
||||
|
||||
#
|
||||
# mount root of the build context as /module/gitea-pages
|
||||
# inside the container and run `xcaddy build` command
|
||||
# also use cache to speed up subsequent builds
|
||||
#
|
||||
# $> go env GOCACHE <<-- Golang build cache
|
||||
# $> go env GOMODCACHE <<-- Goland module download cache
|
||||
#
|
||||
RUN --mount=type=bind,target=/module/gitea-pages \
|
||||
--mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
xcaddy build \
|
||||
--with gitea.djmil.dev/djmil/gitea-pages \
|
||||
--replace gitea.djmil.dev/djmil/gitea-pages=/module/gitea-pages \
|
||||
--replace gitea.djmil.dev/djmil/gitea-pages/pkg/gitea=/module/gitea-pages/pkg/gitea
|
||||
|
||||
FROM caddy:2.8.4
|
||||
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
|
||||
EXPOSE 3003/tcp
|
@ -1,19 +0,0 @@
|
||||
FROM caddy:2.8.4-builder-alpine AS builder
|
||||
|
||||
ARG RELEASE
|
||||
|
||||
#
|
||||
# $> go env GOCACHE <<-- Golang build cache
|
||||
# $> go env GOMODCACHE <<-- Goland module download cache
|
||||
#
|
||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||
--mount=type=cache,target=/go/pkg/mod \
|
||||
xcaddy build \
|
||||
--with gitea.djmil.dev/djmil/gitea-pages@$RELEASE
|
||||
|
||||
FROM caddy:2.8.4
|
||||
|
||||
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
|
||||
EXPOSE 3003/tcp
|
@ -5,7 +5,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"gitea.djmil.dev/djmil/gitea-pages/pkg/gitea"
|
||||
"gitea.djmil.dev/goland/gitea-pages/pkg/gitea"
|
||||
"github.com/caddyserver/caddy/v2"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
|
||||
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
|
||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
||||
module gitea.djmil.dev/djmil/gitea-pages
|
||||
module gitea-pages
|
||||
|
||||
go 1.19
|
||||
|
||||
|
39
make-release.sh
Executable file
39
make-release.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
usage="$(basename "$0") [-h] [-t RELEASE_VERSION ]
|
||||
|
||||
The script compiles Caddy server with GiteaPages plugin, and publishes the resulting image
|
||||
to the https://hub.docker.com/u/djmil
|
||||
|
||||
Where:
|
||||
-t RELEASE_VERSION
|
||||
A major.minor.patch tag for the image being publisdhed.
|
||||
"
|
||||
|
||||
tag=''
|
||||
|
||||
while getopts ht: flag
|
||||
do
|
||||
case "${flag}" in
|
||||
t) tag=${OPTARG};;
|
||||
h) echo "$usage"; exit 0;;
|
||||
*) echo "$usage" >&2; exit 1;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ ! "$tag" ]; then
|
||||
echo 'Missing: -t RELEASE_VERSION' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Tag: $tag";
|
||||
|
||||
docker build --tag djmil/gitea-pages:$tag .
|
||||
|
||||
#git tag
|
||||
#git push tag
|
||||
|
||||
docker login --username djmil #--password-stdin
|
||||
|
||||
docker push djmil/gitea-pages:$tag
|
Loading…
Reference in New Issue
Block a user