add dockerfile based on shlink-web-client

This commit is contained in:
Dmitry Sichkar 2024-01-07 15:38:55 +02:00
parent fb6f5dc141
commit 90aea066ff
4 changed files with 74 additions and 0 deletions

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM shlinkio/shlink-web-client:latest
ENV SHLINK_BASIC_AUTH_USERS 'shlink:$2y$05$60tNO1beevtKPMj/jaSzhuxOn21U2dEOXPOdUA2b.TbZ9007kCoLK'
ENV SHLINK_BASIC_AUTH_NAME 'Shlink Web Client'
RUN sed -i "6 i auth_basic \"SHLINK_BASIC_AUTH_NAME\";\nauth_basic_user_file /etc/nginx/.htpasswd;" /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

23
README.md Normal file
View File

@ -0,0 +1,23 @@
# Shlink Web Client with Basic HTTP Auth
[![Docker Pulls](https://img.shields.io/docker/pulls/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
[![Docker Stars](https://img.shields.io/docker/stars/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
[![Docker Build](https://img.shields.io/docker/automated/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
[![Docker Build Status](https://img.shields.io/docker/build/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
[![Docker Image Size](https://img.shields.io/microbadger/image-size/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
[![Docker Image Layers](https://img.shields.io/microbadger/layers/dmmeteo/shlink-web-client.svg)](https://hub.docker.com/r/dmmeteo/shlink-web-client/)
This repository adds Basic HTTP Auth to the web client of [Shlink][2].
For further documentation see [the official Shlink Dockerhub page][1].
## Environment variables
SHLINK_SERVER_URL: The fully qualified URL for the Shlink server.
SHLINK_SERVER_API_KEY: The API key.
SHLINK_SERVER_NAME: The name to be displayed. Defaults to Shlink if not provided.
SHLINK_BASIC_AUTH_NAME: The name to be displayed in the basic auth dialog (default: Shlink).
SHLINK_BASIC_AUTH_USERS: A comma separated list of users in the form of `user:password` (default: shlink:shlink).
[1]: https://hub.docker.com/r/dmmeteo/shlink-web-client
[2]: https://shlink.io

20
docker-compose.yml Normal file
View File

@ -0,0 +1,20 @@
version: '3'
services:
shlink-ui:
build: .
restart: unless-stopped
environment:
SHLINK_API_KEY: '<your-api-key>'
SHLINK_API_URL: 'http://shlink:8080'
ports:
- 8081:80
depends_on:
- shlink
shlink:
image: shlinkio/shlink:latest
restart: unless-stopped
ports:
- 8080:8080
environment:
SHORT_DOMAIN_HOST: localhost
IS_HTTPS_ENABLED: False

18
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
set -e
if [[ -z "$SHLINK_BASIC_AUTH_USERS" ]]; then
echo "No users found for basic auth"
else
echo "Creating .htpasswd file"
echo "$SHLINK_BASIC_AUTH_USERS" > /etc/nginx/.htpasswd
fi
if [[ -z "$SHLINK_BASIC_AUTH_USERS" ]]; then
echo "No name found for basic auth"
else
echo "Setting basic auth name"
sed -i "s/SHLINK_BASIC_AUTH_NAME/$SHLINK_BASIC_AUTH_NAME/g" /etc/nginx/conf.d/default.conf
fi
exec "$@"