diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5166cce --- /dev/null +++ b/Dockerfile @@ -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;"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..7768106 --- /dev/null +++ b/README.md @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8cb394f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3' +services: + shlink-ui: + build: . + restart: unless-stopped + environment: + SHLINK_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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..6729b95 --- /dev/null +++ b/docker-entrypoint.sh @@ -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 "$@"