From 35e23a6b9224a4ddb2a663a404db5fc44907c2e4 Mon Sep 17 00:00:00 2001 From: Tom Moulard Date: Sun, 10 Jan 2021 18:35:43 +0100 Subject: [PATCH] 2Fauth-docker: init --- .gitignore | 5 ++++ Dockerfile | 64 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 8 ++++++ README.md | 3 +++ docker-compose.yml | 51 ++++++++++++++++++++++++++++++++++++ startup.sh | 8 ++++++ 6 files changed, 139 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100755 startup.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..400c130 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.*.swp + +postgres/ +redis/ +db/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f4ac878 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,64 @@ +FROM composer:2.0 + +WORKDIR /2fauth + +RUN chown 1000:1000 /2fauth + +USER 1000:1000 + +# $(php artisan key:generate) || $(head -c32 /dev/urandom | base64) +# ENV DB_CONNECTION=sqlite +# ENV DB_DATABASE="/2fauth/database/database.sqlite" + +ENV APP_NAME=2FAuth \ + APP_ENV=local \ + APP_DEBUG=false \ + SITE_OWNER=mail@example.com \ + APP_KEY=SomeRandomStringOf32CharsExactly \ + APP_URL=http://localhost \ + IS_DEMO_APP=false \ + LOG_CHANNEL=daily \ + APP_LOG_LEVEL=notice \ + DB_CONNECTION=mysql \ + DB_HOST=127.0.0.1 \ + DB_PORT=3306 \ + DB_DATABASE=homestead \ + DB_USERNAME=homestead \ + DB_PASSWORD=secret \ + CACHE_DRIVER=file \ + SESSION_DRIVER=file \ + MAIL_DRIVER=log \ + MAIL_HOST=smtp.mailtrap.io \ + MAIL_PORT=2525 \ + MAIL_FROM=changeme@example.com \ + MAIL_USERNAME=null \ + MAIL_PASSWORD=null \ + MAIL_ENCRYPTION=null \ + MAIL_FROM_NAME=null \ + MAIL_FROM_ADDRESS=null \ + BROADCAST_DRIVER=log \ + QUEUE_DRIVER=sync \ + SESSION_LIFETIME=12 \ + REDIS_HOST=127.0.0.1 \ + REDIS_PASSWORD=null \ + REDIS_PORT=6379 \ + PUSHER_APP_ID= \ + PUSHER_APP_KEY= \ + PUSHER_APP_SECRET= \ + PUSHER_APP_CLUSTER=mt1 \ + MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" \ + MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" \ + MIX_ENV=local + +RUN git clone -q https://github.com/Bubka/2FAuth /2fauth + +COPY ./startup.sh . + +RUN composer -q install + +RUN mkdir -p database/ && touch database/database.sqlite + +RUN php artisan config:cache +RUN php artisan storage:link + +ENTRYPOINT ["/2fauth/startup.sh"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8408836 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +all: build +all: up + +build: + docker-compose build + +up: + docker-compose up diff --git a/README.md b/README.md new file mode 100644 index 0000000..3802885 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# 2FAuth docker + +A repo with project to bring Docker support to [2Fauth](https://github.com/Bubka/2FAuth) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c09af0b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +version: '3.6' + +networks: + 2fauth-internal: + +services: + 2fauth: + image: tommoulard/2fauth + build: . + ports: + - '80:8080' + environment: + - 'SITE_OWNER=tom@moulard.org' + - 'APP_KEY=${APP_KEY}' + - 'REDIS_HOST=2fauth-redis' + - 'DB_CONNECTION=postgres' + - 'DB_HOST=2fauth-postgres' + - 'DB_PORT=5432' + - 'DB_USER=postgres' + - 'DB_NAME=postgres' + - 'DB_PASSWORD=2fauth-postgres-pass' + volumes: + - './2fauth/db/:/2fauth/database/' + networks: + - '2fauth-internal' + + 2fauth-redis: + image: redis:6.0-alpine + restart: always + networks: + - '2fauth-internal' + healthcheck: + test: ["CMD", "redis-cli", "ping"] + volumes: + - './2fauth/redis:/data' + + 2fauth-postgres: + image: postgres:9.6-alpine + restart: always + user: '1000:1000' + shm_size: 256mb + networks: + - '2fauth-internal' + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + volumes: + - ./2fauth/postgres:/var/lib/postgresql/data + environment: + - POSTGRES_PASSWORD=2fauth-postgres-pass + + diff --git a/startup.sh b/startup.sh new file mode 100755 index 0000000..d119b03 --- /dev/null +++ b/startup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e # exit if fails + +php artisan passport:install +php artisan migrate:refresh + +php -S localhost:80