mirror of
				https://github.com/qdm12/caddy-scratch.git
				synced 2022-03-12 19:25:15 +03:00 
			
		
		
		
	Initial commit
This commit is contained in:
		
							
								
								
									
										7
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.dockerignore
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| .gitignore | ||||
| .travis.yml | ||||
| README.md | ||||
| docker-compose.yml | ||||
| .git/ | ||||
| title.png | ||||
| *.exe | ||||
							
								
								
									
										0
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										7
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.travis.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| language: generic | ||||
| services: | ||||
|   - docker | ||||
| install: | ||||
|   - docker build . | ||||
| after_script: | ||||
|   - "curl -X POST https://hooks.microbadger.com/images/qmcgaw/caddy-scratch/WEBHOOK_LINK" | ||||
							
								
								
									
										52
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| ARG ALPINE_VERSION=3.8 | ||||
| ARG GO_VERSION=1.11.4 | ||||
|  | ||||
| FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder | ||||
| ARG PLUGINS=minify,ipfilter,nobots,ratelimit | ||||
| # Extra plugins: realip,forwardproxy | ||||
| ARG TELEMETRY=false | ||||
| RUN apk add --progress --update git gcc musl-dev ca-certificates | ||||
| WORKDIR /go/src/github.com/mholt/caddy | ||||
| RUN git clone --branch v0.11.1 --single-branch --depth 1 https://github.com/mholt/caddy /go/src/github.com/mholt/caddy && \ | ||||
|     $TELEMETRY || sed -i 's/var EnableTelemetry = true/var EnableTelemetry = false/' /go/src/github.com/mholt/caddy/caddy/caddymain/run.go | ||||
| RUN git clone https://github.com/caddyserver/builds /go/src/github.com/caddyserver/builds | ||||
| RUN GOOS=linux GOARCH=amd64 go get -v github.com/abiosoft/caddyplug/caddyplug | ||||
| RUN for plugin in $(echo $PLUGINS | tr "," " "); do \ | ||||
|       go get -v $(GOOS=linux GOARCH=amd64 caddyplug package $plugin) && \ | ||||
|       printf "package caddyhttp\nimport _ \"$(GOOS=linux GOARCH=amd64 caddyplug package $plugin)\"" > /go/src/github.com/mholt/caddy/caddyhttp/$plugin.go; \ | ||||
|     done | ||||
| RUN cd caddy && \ | ||||
|     go run build.go -goos=linux -goarch=amd64 | ||||
|  | ||||
| FROM alpine:${ALPINE_VERSION} AS alpine | ||||
| RUN apk --update add ca-certificates | ||||
|  | ||||
| FROM scratch | ||||
| ARG BUILD_DATE | ||||
| ARG VCS_REF | ||||
| LABEL org.label-schema.schema-version="1.0.0-rc1" \ | ||||
|       maintainer="quentin.mcgaw@gmail.com" \ | ||||
|       org.label-schema.build-date=$BUILD_DATE \ | ||||
|       org.label-schema.vcs-ref=$VCS_REF \ | ||||
|       org.label-schema.vcs-url="https://github.com/qdm12/caddy-scratch" \ | ||||
|       org.label-schema.url="https://github.com/qdm12/caddy-scratch" \ | ||||
|       org.label-schema.vcs-description="Caddy server on a Scratch base image" \ | ||||
|       org.label-schema.vcs-usage="https://github.com/qdm12/caddy-scratch/blob/master/README.md#setup" \ | ||||
|       org.label-schema.docker.cmd="docker run -d -v $(pwd)/Caddyfile:/Caddyfile:ro -v $(pwd)/data:/data -v $(pwd)/srv:/srv:ro -p 80:8080/tcp -p 443:8443/tcp -p 2015:2015/tcp qmcgaw/caddy-scratch" \ | ||||
|       org.label-schema.docker.cmd.devel="docker run -it --rm -v $(pwd)/Caddyfile:/Caddyfile:ro -p 80:8080/tcp -p 443:8443/tcp -p 2015:2015/tcp qmcgaw/caddy-scratch" \ | ||||
|       org.label-schema.docker.params="" \ | ||||
|       org.label-schema.version="" \ | ||||
|       image-size="20.5MB" \ | ||||
|       ram-usage="MB" \ | ||||
|       cpu-usage="Depends" | ||||
| COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||||
| EXPOSE 8080 8443 2015 | ||||
| # HEALTHCHECK --interval=100s --timeout=3s --start-period=10s --retries=1 CMD ["/healthcheck"]    | ||||
| ENV HOME=/ \ | ||||
|     CADDYPATH=/data | ||||
| VOLUME ["/data"] | ||||
| USER 1000 | ||||
| ENTRYPOINT ["/caddy","-conf","/Caddyfile","-log","stdout","-agree"] | ||||
| CMD ["-http-port","8080","-https-port","8443"] | ||||
| # see https://caddyserver.com/docs/cli | ||||
| COPY --from=builder /go/src/github.com/mholt/caddy/caddy/caddy /caddy | ||||
							
								
								
									
										21
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| MIT License | ||||
|  | ||||
| Copyright (c) 2019 Quentin McGaw | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| of this software and associated documentation files (the "Software"), to deal | ||||
| in the Software without restriction, including without limitation the rights | ||||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
| copies of the Software, and to permit persons to whom the Software is | ||||
| furnished to do so, subject to the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be included in all | ||||
| copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
| SOFTWARE. | ||||
							
								
								
									
										64
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| # Caddy Scratch Docker | ||||
|  | ||||
| *Caddy server with plugins on a Scratch base Docker image* | ||||
|  | ||||
| [](https://hub.docker.com/r/qmcgaw/caddy-scratch) | ||||
|  | ||||
| [](https://travis-ci.org/qdm12/caddy-scratch) | ||||
| [](https://hub.docker.com/r/qmcgaw/caddy-scratch) | ||||
|  | ||||
| [](https://github.com/qdm12/caddy-scratch/issues) | ||||
| [](https://github.com/qdm12/caddy-scratch/issues) | ||||
| [](https://github.com/qdm12/caddy-scratch/issues) | ||||
|  | ||||
| [](https://hub.docker.com/r/qmcgaw/caddy-scratch) | ||||
| [](https://hub.docker.com/r/qmcgaw/caddy-scratch) | ||||
| [](https://hub.docker.com/r/qmcgaw/caddy-scratch) | ||||
|  | ||||
| [](https://microbadger.com/images/qmcgaw/caddy-scratch) | ||||
| [](https://microbadger.com/images/qmcgaw/caddy-scratch) | ||||
|  | ||||
| | Image size | RAM usage | CPU usage | | ||||
| | --- | --- | --- | | ||||
| | 20.5MB | MB | Depends | | ||||
|  | ||||
| It is based on: | ||||
|  | ||||
| - [Scratch](https://hub.docker.com/_/scratch/) | ||||
| - [Caddy 0.11.1](https://github.com/mholt/caddy) | ||||
|  | ||||
| ## Setup | ||||
|  | ||||
| Use the following command: | ||||
|  | ||||
| ```bash | ||||
| docker run -d \ | ||||
| -v $(pwd)/Caddyfile:/Caddyfile:ro \ | ||||
| -v $(pwd)/data:/data \ | ||||
| -v $(pwd)/srv:/srv:ro \ | ||||
| -p 80:8080/tcp -p 443:8443/tcp -p 2015:2015/tcp \ | ||||
| qmcgaw/caddy-scratch | ||||
| ``` | ||||
|  | ||||
| or use [docker-compose.yml](https://github.com/qdm12/caddy-scratch/blob/master/docker-compose.yml) with: | ||||
|  | ||||
| ```bash | ||||
| docker-compose up -d | ||||
| ``` | ||||
|  | ||||
| ### Environment variables | ||||
|  | ||||
| | Environment variable | Default | Possible values | Description | | ||||
| | --- | --- | --- | --- | | ||||
| | `` | `` | `` | | | ||||
|  | ||||
| ## TODOs | ||||
|  | ||||
| - [ ] Use lists of IPs to block with ipfilter with `import blockIps` | ||||
| - [ ] Healthcheck for Caddy | ||||
| - [ ] Fix reloading of Caddyfile with SIGUSR1 | ||||
| - [ ] Intelligent IP blocking | ||||
|  | ||||
| ## License | ||||
|  | ||||
| This repository is under an [MIT license](https://github.com/qdm12/caddy-scratch/master/license) | ||||
							
								
								
									
										17
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								docker-compose.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| version: '3' | ||||
| services: | ||||
|   caddy: | ||||
|     build: https://github.com/qdm12/caddy-scratch.git | ||||
|     image: qmcgaw/caddy-scratch | ||||
|     container_name: caddy | ||||
|     volumes: | ||||
|       - ./Caddyfile:/Caddyfile:ro | ||||
|       - ./data:/data | ||||
|       - ./srv:/srv:ro | ||||
|     network_mode: bridge | ||||
|     ports: | ||||
|       - 80:8080/tcp | ||||
|       - 443:8443/tcp | ||||
|       - 2015:2015/tcp | ||||
|     #environment: | ||||
|     restart: always | ||||
							
								
								
									
										9
									
								
								hooks/build
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								hooks/build
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # see http://label-schema.org/rc1 | ||||
| # https://docs.docker.com/docker-cloud/builds/advanced/#override-build-test-or-push-commands | ||||
| # https://docs.docker.com/docker-cloud/builds/advanced/#custom-build-phase-hooks | ||||
|  | ||||
| docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ | ||||
|              --build-arg VCS_REF=`git rev-parse --short HEAD` \ | ||||
|              -t $IMAGE_NAME . | ||||
		Reference in New Issue
	
	Block a user
	 Quentin McGaw
					Quentin McGaw