Browse Source

add docker support

master
bn4t 5 months ago
parent
commit
5a5cad2551
4 changed files with 96 additions and 1 deletions
  1. +34
    -0
      .drone.yml
  2. +20
    -0
      Dockerfile
  3. +16
    -1
      README.md
  4. +26
    -0
      docker-compose.yml

+ 34
- 0
.drone.yml View File

@@ -0,0 +1,34 @@
kind: pipeline
name: default

steps:
- name: build
image: docker:dind
environment:
USERNAME:
from_secret: registry_username
PASSWORD:
from_secret: registry_password
volumes:
- name: dockersock
path: /var/run
commands:
- sleep 5 # give docker enough time to start
- docker login -u $USERNAME -p $PASSWORD registry.bn4t.me
- docker build --pull -t registry.bn4t.me/bn4t/csp-handler:latest .
- docker push registry.bn4t.me/bn4t/csp-handler:latest
when:
branch:
- master

services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run

volumes:
- name: dockersock
temp: {}

+ 20
- 0
Dockerfile View File

@@ -0,0 +1,20 @@
FROM golang:alpine as builder

RUN mkdir /build /out && apk add --no-cache git ca-certificates

WORKDIR /build
COPY . .
RUN go get && go build -o /out/csp-handler





FROM alpine:latest

RUN mkdir /app && addgroup -S csp-handler && adduser -S csp-handler -G csp-handler && apk add --no-cache ca-certificates
COPY --from=builder /out/csp-handler /app/csp-handler
USER csp-handler

ENTRYPOINT /app/csp-handler


+ 16
- 1
README.md View File

@@ -3,4 +3,19 @@


### Important
**CSP-Handler needs to be behind a reverse proxy which forwards either the `X-Forwarded-For` or `X-Real-IP` header, else ratelimiting won't work.**
**CSP-Handler needs to be behind a reverse proxy which forwards either the `X-Forwarded-For` or `X-Real-IP` header, else ratelimiting won't work.**



## Setup


1. Clone the repository and enter the directory: `git clone https://git.bn4t.me/bn4t/csp-handler.git
&& cd csp-handler`
2. Edit the environment variables in `docker-compose.yml`
3. Build the image and start the container: `docker-compose up --build -d`


## License

GPLv3

+ 26
- 0
docker-compose.yml View File

@@ -0,0 +1,26 @@
version: '2.2'

services:
release-bot:
build: .
image: csp-handler
environment:
# Email Address to use to send mails
- SENDER_EMAIL=csp@example.com

# Email address to which the report mails are being sent
- RECEIVER_EMAIL=alice@example.com

# SMTP server address in following format: smtp.example.tld:465
- SMTP_ADDRESS=mail.example.com:465

# SMTP username
- SMTP_USERNAME=me@example.com

# SMTP Password
- SMTP_PASSWORD=P4ssw0rd

# Limit the requests a single IP address can make in an hour
- RATE_LIMIT=1
restart: always


Loading…
Cancel
Save