Add docker image
This commit is contained in:
parent
abd5b21817
commit
17b538f297
|
@ -0,0 +1,20 @@
|
||||||
|
FROM golang:1.16.0-buster as BUILD
|
||||||
|
|
||||||
|
COPY . mastogem
|
||||||
|
|
||||||
|
RUN cd mastogem && \
|
||||||
|
go build -o /mastogem
|
||||||
|
|
||||||
|
FROM debian:buster-slim
|
||||||
|
|
||||||
|
COPY --from=BUILD /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|
||||||
|
COPY --from=BUILD /mastogem /mastogem
|
||||||
|
|
||||||
|
COPY start.sh /start.sh
|
||||||
|
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
EXPOSE 1965
|
||||||
|
|
||||||
|
CMD "/start.sh"
|
12
Makefile
12
Makefile
|
@ -1,9 +1,15 @@
|
||||||
all: amd64 arm7
|
VERSION=1.0
|
||||||
|
SOURCES=$(shell find . -name "*.go" -type f)
|
||||||
|
|
||||||
amd64:
|
all: amd64 arm7 dockerimage
|
||||||
|
|
||||||
|
amd64: $(SOURCES)
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
GOOS=linux GOARCH=amd64 go build -o build/mastogem-amd64
|
GOOS=linux GOARCH=amd64 go build -o build/mastogem-amd64
|
||||||
|
|
||||||
arm7:
|
arm7: $(SOURCES)
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
GOOS=linux GOARCH=arm GOARM=7 go build -o build/mastogem-arm7
|
GOOS=linux GOARCH=arm GOARM=7 go build -o build/mastogem-arm7
|
||||||
|
|
||||||
|
dockerimage: Dockerfile start.sh $(SOURCES)
|
||||||
|
sudo docker build -t dervom/mastogem:$(VERSION) .
|
||||||
|
|
23
README.md
23
README.md
|
@ -31,6 +31,29 @@ You should provide the `MASTOGEM_CONFIG_PATH` environment variable when launchin
|
||||||
|
|
||||||
To run the program simply run the executable file corresponding to your architecture in the `build` folder. Make sure the certificate and the key where generated before.
|
To run the program simply run the executable file corresponding to your architecture in the `build` folder. Make sure the certificate and the key where generated before.
|
||||||
|
|
||||||
|
## Run with Docker
|
||||||
|
|
||||||
|
You could use docker or docker-compose to run this program, you must set a `MASTODON_BASE_URL` variable corresponding to the URL to your Mastodon instance (without the tailing slash), you also must bind a certificate (`/cert.pem`) and a key (`/key.rsa`).
|
||||||
|
|
||||||
|
You can set a `TITLE` and a `HOME_MESSAGE` variables.
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo docker run -it \
|
||||||
|
-p 1965:1965 \
|
||||||
|
-e MASTODON_BASE_URL=https://mamot.fr \
|
||||||
|
--mount type=bind,source=$(pwd)/certs/cert.pem,destination=/cert.pem \
|
||||||
|
--mount type=bind,source=$(pwd)/certs/key.rsa,destination=/key.rsa \
|
||||||
|
dervom/mastogem
|
||||||
|
```
|
||||||
|
|
||||||
|
### Docker-compose
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
You contributions are welcomed, you can send me an email (romain.delaage@rdelaage.ovh).
|
You contributions are welcomed, you can send me an email (romain.delaage@rdelaage.ovh).
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
mastogem:
|
||||||
|
image: dervom/mastogem:1.0
|
||||||
|
build: .
|
||||||
|
container_name: mastogem
|
||||||
|
volumes:
|
||||||
|
- ./certs/key.rsa:/key.rsa:ro
|
||||||
|
- ./certs/cert.pem:/cert.pem:ro
|
||||||
|
environment:
|
||||||
|
MASTODON_BASE_URL: "https://mamot.fr"
|
||||||
|
ports:
|
||||||
|
- 1965:1965
|
||||||
|
restart: unless-stopped
|
|
@ -0,0 +1,41 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
if [ -z "$MASTODON_BASE_URL" ]
|
||||||
|
then
|
||||||
|
echo "You must set the MASTODON_BASE_URL variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /cert.pem ]
|
||||||
|
then
|
||||||
|
echo "You must bind a certificate at /cert.pem"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /key.rsa ]
|
||||||
|
then
|
||||||
|
echo "You must bind a private key at /key.rsa"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TITLE" ]
|
||||||
|
then
|
||||||
|
TITLE=MastoGem
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$HOME_MESSAGE" ]
|
||||||
|
then
|
||||||
|
HOME_MESSAGE="Welcome on MastoGem, a Mastodon proxy for Gemini !"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF > /config.json
|
||||||
|
{
|
||||||
|
"listen": "0.0.0.0:1965",
|
||||||
|
"cert_path": "/cert.pem",
|
||||||
|
"key_path": "/key.rsa",
|
||||||
|
"base_url": "$MASTODON_BASE_URL",
|
||||||
|
"title": "$TITLE",
|
||||||
|
"home_message": "$HOME_MESSAGE"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
MASTOGEM_CONFIG_PATH=/config.json /mastogem
|
Loading…
Reference in New Issue