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

added docker image files #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ install: fiche
clean:
rm -f fiche

docker:
docker build --tag solusipse/fiche --build-arg ALPINE_VERSION=3.20 .

.PHONY: clean
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ To use fiche you have to have netcat installed. You probably already have it - t

# Server-side usage

## Installation
## Installation (source)

1. Clone:

Expand All @@ -131,6 +131,24 @@ To use fiche you have to have netcat installed. You probably already have it - t
sudo make install
```

## Installation (docker)

1. Clone:

```
git clone https://github.com/solusipse/fiche.git
```
2. Customize environment variables

```
nano docker-compose.yml
```
3. Launch

```
docker compose up -d
```

### Using Ports on FreeBSD

To install the port: `cd /usr/ports/net/fiche/ && make install clean`. To add the package: `pkg install fiche`.
Expand Down
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
services:
fiche:
image: solusipse/fiche
restart: unless-stopped
environment:
- HTTPS=no
- OUTPUT_DIRECTORY=/opt/fiche/code
- DOMAIN=example.com
- SLUG_SIZE=4
- BUFFER_SIZE=32768
ports:
- 9999:9999
volumes:
- fiche-code:/opt/fiche/code
web:
image: nginx
restart: unless-stopped
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./nginx-site.conf:/etc/nginx/conf.d/default.conf
- fiche-code:/var/www/html

volumes:
fiche-code:
48 changes: 48 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env sh
set -e
args=""

# Check environment variables and set construct the cmd line accordingly
if [ "${HTTPS}" = "yes" ] || [ "${HTTPS}" = "true" ]; then
args="${ARGS} -S"
fi
if [ ! -z "${OUTPUT_DIRECTORY}" ]; then
args="${args} -o ${OUTPUT_DIRECTORY}"
fi
if [ ! -z "${DOMAIN}" ]; then
args="${ARGS} -d ${DOMAIN}"
fi
if [ ! -z "${SLUG_SIZE}" ]; then
args="${ARGS} -s ${SLUG_SIZE}"
fi
if [ ! -z "${BUFFER_SIZE}" ]; then
args="${ARGS} -B ${BUFFER_SIZE}"
fi
if [ ! -z "${LOG_FILE}" ]; then
args="${ARGS} -b ${LOG_FILE}"
fi

###
# FUTURE DEVELOPMENT
###
#if [ ! -z "${WHITELIST_FILE}" ]; then
# args="${ARGS} -w ${WHITELIST_FILE}"
#fi
#if [ ! -z "${BANLIST_FILE}" ]; then
# args="${ARGS} -b ${BANLIST_FILE}"
#fi

/usr/local/bin/fiche "${args}" &
FICHE_PID=$!

# Close trap function
close() {
kill -SIGTERM "$FICHE_PID"
}

# Trap SIGTERM and SIGINT
trap "close" SIGTERM
trap "close" SIGINT

# Wait for Fiche (in case it crashes, etc)
wait "$FICHE_PID"
25 changes: 25 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
ARG ALPINE_VERSION="3"
# Stage 1 · builder
FROM alpine:${ALPINE_VERSION} AS builder

WORKDIR /usr/src/fiche
COPY . .

RUN apk update && apk add \
make \
gcc \
g++ && \
make && \
make install && \
make clean

# Stage 2 · app
FROM alpine:${ALPINE_VERSION} AS app

WORKDIR /opt/fiche
COPY --from=builder /usr/local/bin/fiche /usr/local/bin/fiche
COPY docker-entrypoint.sh /docker-entrypoint.sh

VOLUME /opt/fiche/code

ENTRYPOINT ["/docker-entrypoint.sh"]
16 changes: 16 additions & 0 deletions nginx-site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.txt index.html;
charset utf-8;

location / {
try_files $uri $uri/ =404;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
31 changes: 31 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
user nginx;
worker_processes auto;

error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

gzip off;
server_tokens off;

include /etc/nginx/conf.d/*.conf;
}