Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Adding proxying support #40

Merged
merged 23 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ["https://paypal.me/matthiasluedtke"]
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: go
go:
- "1.10.x"
- "1.11.x"
- "1.12"
- "1.12.1"
- "1.12.2"
- "1.12.3"
- "1.12.4"
- "1.12.x"
- "1.13"
- "1.13.1"
- "1.13.2"
- "1.13.3"
script: make test_all
34 changes: 23 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
FROM alpine:3.8
LABEL maintainer="Matthias Luedtke (matthiasluedtke)"
# Adapted from
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy#containerizing

RUN apk add --no-cache ca-certificates
# Fixes 'Get https://github.com/: x509: failed to
# load system roots and no roots provided'
# Use the offical Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.13 as builder

# Copy local code to the container image.
WORKDIR /go/src/github.com/mat/besticon
COPY . .

# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy
COPY bin/linux_amd64/iconserver /var/www/iconserver
# Build the command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN make build_linux_amd64

# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3.10
RUN apk add --no-cache ca-certificates

EXPOSE 8080
ENV PORT=8080
# Copy the binary to the production image from the builder stage.
COPY --from=builder /go/src/github.com/mat/besticon/bin/linux_amd64/iconserver /iconserver

ENV HOST_ONLY_DOMAINS=*
ENV POPULAR_SITES=bing.com,github.com,instagram.com,reddit.com
ENV HTTP_CLIENT_TIMEOUT=5s
ENV HTTP_MAX_AGE_DURATION=720h

WORKDIR /var/www
CMD ["./iconserver"]
# Run the web service on container startup.
CMD ["/iconserver"]
58 changes: 33 additions & 25 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@

[metadata.heroku]
root-package = "github.com/mat/besticon"
go-version = "go1.12"
go-version = "go1.13"
install = [ "./..." ]
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ github_package: clean build_all_platforms
file iconserver*.zip
ls -alht iconserver*.zip

build_docker_image: build_linux_amd64
## Docker ##
docker_build_image:
docker build -t matthiasluedtke/iconserver:latest -t matthiasluedtke/iconserver:`cat VERSION` .

push_docker_image:
docker_run:
docker run -p 3000:8080 --env-file docker_run.env matthiasluedtke/iconserver:latest

docker_push_images_all: docker_push_image_latest docker_push_image_version

docker_push_image_latest:
docker push matthiasluedtke/iconserver:latest

docker_push_image_version:
docker push matthiasluedtke/iconserver:`cat VERSION`

new_release: bump_version rewrite-version.go git_tag_version
Expand Down
14 changes: 9 additions & 5 deletions Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Try out the demo at <https://besticon-demo.herokuapp.com> or find out how to [de

[![Build Status](https://travis-ci.org/mat/besticon.svg?branch=master)](https://travis-ci.org/mat/besticon)
[![Go Report Card](https://goreportcard.com/badge/github.com/mat/besticon)](https://goreportcard.com/report/github.com/mat/besticon)
[![Donate at PayPal](https://img.shields.io/badge/paypal-donate-orange.svg?style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6F9YBSSCM6KCW "Donate once-off to this project using Paypal")
[![Donate at PayPal](https://img.shields.io/badge/paypal-donate-orange.svg?style=flat)](https://paypal.me/matthiasluedtke "Donate once-off to this project using Paypal")


## What's this?
Expand Down Expand Up @@ -70,7 +70,10 @@ Feel free to file other bugs - and offer your help - at <https://github.com/mat/

## Hosting

An easy way to host this service is to use Heroku, just go to <https://heroku.com/deploy> to get started.
Simple options to host this service are, for example:

- Heroku: <https://heroku.com/deploy>
- Google Cloud Run: <https://deploy.cloud.run>

## Docker

Expand All @@ -90,7 +93,7 @@ Binaries for some operating systems can be downloaded from <https://github.com/m

### Build your own

If you have Go 1.11 installed on your system you can use `go get` to fetch the source code and build the server:
If you have Go installed on your system you can use `go get` to fetch the source code and build the server:

$ go get -u github.com/mat/besticon/...

Expand Down Expand Up @@ -124,7 +127,7 @@ There is not a lot to configure but these environment variables exist
| `HTTP_CLIENT_TIMEOUT` | Timeout used for HTTP requests. Supports units like ms, s, m. | 5s |
| `HTTP_MAX_AGE_DURATION` | Cache duration for all dynamically generated HTTP responses. Supports units like ms, s, m. | 720h *(30 days)* |
| `POPULAR_SITES` | Comma-separated list of domains used on /popular page | |

| `SERVER_MODE` | Set to `download` to proxy downloads through Besticon or `redirect` to let browser to download instead. | `redirect` |
## Libraries etc.

Package | Description | License
Expand All @@ -145,6 +148,7 @@ Package | Description | License
* Erkie - https://github.com/erkie
* mmkal - https://github.com/mmkal
* kspearrin - https://github.com/kspearrin
* karl-ravn - https://github.com/karl-ravn

## License

Expand Down Expand Up @@ -174,4 +178,4 @@ SOFTWARE.

If you find this useful and want to donate... you would make my day :-)

[![Donate at PayPal](https://img.shields.io/badge/paypal-donate-orange.svg?style=flat)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6F9YBSSCM6KCW "Donate once-off to this project using Paypal")
[![Donate at PayPal](https://img.shields.io/badge/paypal-donate-orange.svg?style=flat)](https://paypal.me/matthiasluedtke "Donate once-off to this project using Paypal")
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.9.0
v3.10.0
22 changes: 16 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
{
"name": "favicon-service (besticon)",
"name": "besticon-favicon-service",
"description": "A favicon service written in Go",
"repository": "https://github.com/mat/besticon",
"website": "https://github.com/mat/besticon",
"logo": "https://besticon-demo.herokuapp.com/icon.svg",
"env": {
"CACHE_SIZE_MB": "64",
"HOST_ONLY_DOMAINS": "*",
"HTTP_CLIENT_TIMEOUT": "5s",
"HTTP_MAX_AGE_DURATION": "720h",
"POPULAR_SITES": "bing.com,github.com,instagram.com,reddit.com"
"CACHE_SIZE_MB": {
"value": "64"
},
"HOST_ONLY_DOMAINS": {
"value": "*"
},
"HTTP_CLIENT_TIMEOUT": {
"value": "5s"
},
"HTTP_MAX_AGE_DURATION": {
"value": "720h"
},
"POPULAR_SITES": {
"value": "github.com"
}
}
}
Loading