Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
07716fe
Initial commit (WIP)
qdm12 Jul 29, 2021
8f6c9e2
Change entrypoint to actual entrypoint script
qdm12 Jul 29, 2021
1da1fa0
Entrypoint fails on any error
qdm12 Jul 29, 2021
bfc7ca9
Entrypoint cleanup routine
qdm12 Jul 29, 2021
94222e5
Add log about Nginx listening
qdm12 Jul 29, 2021
dcc3c23
Minor changes
qdm12 Jul 29, 2021
22d7013
Fix ownership for php-fpm logs
qdm12 Jul 29, 2021
1e1244a
Remove Nginx duplicate setup block
qdm12 Jul 31, 2021
f5f16f3
Rework Dockerfile:
qdm12 Jul 31, 2021
c89aa75
Add docker-compose.yml
qdm12 Jul 31, 2021
d20a326
Add 'do not remove me' to installed file
qdm12 Jul 31, 2021
404345a
Change .sqlite to database.sqlite
qdm12 Jul 31, 2021
165668f
Symlink storage
qdm12 Jul 31, 2021
44d21c7
Add docker/README.md
qdm12 Jul 31, 2021
92029c4
Fix permission for entrypoint for build on Linux
qdm12 Jul 31, 2021
9310b28
Fix restart of container
qdm12 Jul 31, 2021
9d40eab
Update TODOs
qdm12 Jul 31, 2021
6d674eb
Add dockeri.co dynamic image
qdm12 Aug 1, 2021
fd9a24e
Doc: change image size text to badge
qdm12 Aug 1, 2021
2141f2c
Doc: add reference to Docker document in main readme
qdm12 Aug 1, 2021
ced2aeb
Change qmcgaw/2fauth to 2fauth/2fauth
qdm12 Aug 1, 2021
b7f6388
Doc: add Update section with docker pull
qdm12 Aug 1, 2021
1f4aac8
Doc: build the image section
qdm12 Aug 1, 2021
3751e46
Configure nginx to log to stdout and stderr
qdm12 Aug 2, 2021
d638b8f
Verify Nginx config at build time
qdm12 Aug 2, 2021
cb1efd5
Use supervisord for Nginx+php-fpm
qdm12 Aug 2, 2021
a825246
Horribly ugly suffix empty space
qdm12 Aug 2, 2021
544a448
Show program versions at start
qdm12 Aug 2, 2021
1a04a75
No need for /var/www/.composer dir
qdm12 Aug 2, 2021
2a63caa
Simplify entrypoint if else blocks
qdm12 Aug 2, 2021
b4d8a12
Use absolute paths in supervisor config
qdm12 Aug 2, 2021
8c65d16
Remove nginx commented lines
qdm12 Aug 2, 2021
5be6724
Download and build vendor deps in separate stage
qdm12 Aug 2, 2021
d6215a0
Change Dockerfile for cross building
qdm12 Aug 2, 2021
f74b40f
Add Docker Hub description workflow
qdm12 Aug 2, 2021
b1d4717
Use PHP image to get vendor dependencies (faster)
qdm12 Aug 3, 2021
16225e4
Pin PHP version to 7.3-buster
qdm12 Aug 3, 2021
e9a517f
Add test stage
qdm12 Aug 3, 2021
1f5b476
Docker ignore webpack.mix.js
qdm12 Aug 3, 2021
46b99fe
Add opencontainers labels
qdm12 Aug 3, 2021
f0eb186
Add Github Actions workflow for Docker\
qdm12 Aug 3, 2021
482e97e
Migrate if installed commit differs from program commit
qdm12 Aug 3, 2021
2567906
Docs: change database section
qdm12 Aug 3, 2021
6a6e19f
Docs: clean up todos
qdm12 Aug 3, 2021
82e1999
Add trailing new line in ci.yml
qdm12 Aug 3, 2021
25933bd
Doc: add build status badge for ci.yml
qdm12 Aug 3, 2021
c24f5b2
Remove support for mysql
qdm12 Aug 4, 2021
08af4ef
Remove ignored directives from php-fpm pool config
qdm12 Aug 4, 2021
de7a3ca
UID and GID as build arguments
qdm12 Aug 4, 2021
4743313
Log out version, commit and build date at start
qdm12 Aug 4, 2021
76a5c1a
Add section to build image for specific release to docker readme
qdm12 Aug 4, 2021
ce263e4
Docs: docker readme: Build the image with build arguments
qdm12 Aug 4, 2021
78ba73f
Change to Alpine for x2 smaller image
qdm12 Aug 4, 2021
e3da58d
CI: only run publish job if on base repo
qdm12 Aug 4, 2021
364939f
Add trailing new line to docker hub readme workflow
qdm12 Aug 4, 2021
0f1af9d
Docs: docker readme final pass
qdm12 Aug 4, 2021
0e7ddcb
Only run DockerHub description workflow on base repo
qdm12 Aug 4, 2021
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
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.github
tests
.dockerignore
.editorconfig
.env.example
.env.testing
.gitattributes
.gitignore
.styleci.yml
.travis.yml
changelog.md
Dockerfile
LICENSE
README.md
webpack.mix.js
111 changes: 111 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: CI
on:
push:
paths:
- .github/workflows/ci.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php
pull_request:
paths:
- .github/workflows/ci.yml
- app/**
- bootstrap/**
- config/**
- database/**
- docker/**
- public/**
- resources/**
- routes/**
- storage/**
- tests/**
- .dockerignore
- .env.travis
- artisan
- composer.json
- composer.lock
- Dockerfile
- phpunit.xml
- server.php

jobs:
verify:
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/[email protected]

- name: Build test image
run: docker build --target test -t test-container .

- name: Run tests in test container
run: |
touch coverage.txt
docker run --rm \
test-container

- name: Build final image
run: docker build .

publish:
needs: [verify]
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1

- uses: docker/login-action@v1
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Set variables
id: vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
BRANCH=${GITHUB_REF#refs/heads/}
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
if [ "$TAG" != "$GITHUB_REF" ]; then
echo ::set-output name=version::$TAG
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
elif [ "$BRANCH" = "master" ]; then
echo ::set-output name=version::latest
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
else
echo ::set-output name=version::$BRANCH
echo ::set-output name=platforms::linux/amd64
fi

- name: Build and push final image
uses: docker/[email protected]
with:
platforms: ${{ steps.vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.vars.outputs.created }}
COMMIT=${{ steps.vars.outputs.commit }}
VERSION=${{ steps.vars.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.vars.outputs.version }}
push: true
21 changes: 21 additions & 0 deletions .github/workflows/dockerhub-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docker Hub description
on:
push:
branches: [master]
paths:
- docker/README.md
- .github/workflows/dockerhub-readme.yml
jobs:
dockerHubDescription:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Docker Hub Description
uses: peter-evans/[email protected]
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md
181 changes: 181 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
ARG BUILDPLATFORM=linux/amd64
ARG TARGETPLATFORM
ARG DEBIAN_VERSION=buster-slim
ARG PHP_VERSION=7.3-buster
ARG COMPOSER_VERSION=2.1
ARG SUPERVISORD_VERSION=v0.7.3

FROM --platform=${BUILDPLATFORM} composer:${COMPOSER_VERSION} AS build-composer
FROM composer:${COMPOSER_VERSION} AS composer
FROM qmcgaw/binpot:supervisord-${SUPERVISORD_VERSION} AS supervisord

FROM --platform=${BUILDPLATFORM} php:${PHP_VERSION} AS vendor
ENV DEBIAN_FRONTEND=noninteractive
COPY --from=build-composer --chown=www-data /usr/bin/composer /usr/bin/composer
RUN apt-get update && \
apt-get install -y --no-install-recommends unzip && \
rm -rf /var/cache/* /var/lib/apt/lists/*
WORKDIR /srv
COPY artisan composer.json composer.lock ./
COPY database ./database
RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader

FROM --platform=${BUILDPLATFORM} vendor AS test
COPY . .
RUN mv .env.travis .env
RUN composer install
RUN php artisan key:generate
ENTRYPOINT [ "/srv/vendor/bin/phpunit" ]

FROM debian:${DEBIAN_VERSION}
ENV DEBIAN_FRONTEND=noninteractive

# Composer 2
COPY --from=composer --chown=www-data /usr/bin/composer /usr/bin/composer
# Supervisord from https://github.com/ochinchina/supervisord
COPY --from=supervisord --chown=www-data /bin /usr/local/bin/supervisord

# Install PHP and PHP system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
# PHP
php7.3 \
# PHP SQL drivers
php7.3-sqlite3 php7.3-mysql \
# PHP extensions
php-xml php7.3-gd php7.3-mbstring \
# Nginx and PHP FPM to serve over HTTP
php7.3-fpm nginx \
&& \
# Clean up
apt-get clean && \
rm -rf /var/cache/* /var/lib/apt/lists/* /etc/nginx/nginx.conf && \
# Fix ownership to www-data
chown -R www-data /var/log/nginx /var/lib/nginx/

# PHP FPM configuration
# Pre-create files with the correct permissions
RUN mkdir /run/php && \
touch /var/log/php7.3-fpm.log && \
chown www-data /run/php /var/log/php7.3-fpm.log && \
chmod 700 /run/php /var/log/php7.3-fpm.log

# Nginx configuration
EXPOSE 8000/tcp
RUN touch /run/nginx.pid && \
chown www-data /run/nginx.pid
COPY --chown=www-data docker/nginx.conf /etc/nginx/nginx.conf
RUN nginx -t

# Supervisord configuration
COPY --chown=www-data docker/supervisord.conf /etc/supervisor/supervisord.conf

# Create end user directory
RUN mkdir -p /2fauth && \
chown -R www-data /2fauth && \
chmod 700 /2fauth

# Create /srv internal directory
WORKDIR /srv
RUN chown -R www-data /srv && \
chmod 700 /srv

# Run without root
USER www-data

# Dependencies
COPY --from=vendor --chown=www-data /srv/vendor /srv/vendor

# Copy the rest of the code
COPY --chown=www-data . .
RUN composer dump-autoload --no-scripts --no-dev --optimize

# Entrypoint
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
COPY --chown=www-data docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 500 /usr/local/bin/entrypoint.sh

ENV \
# You can change the name of the app
APP_NAME=2FAuth \
# You can leave this on "local". If you change it to production most console commands will ask for extra confirmation.
# Never set it to "testing".
APP_ENV=local \
# Set to true if you want to see debug information in error screens.
APP_DEBUG=false \
# This should be your email address
[email protected] \
# The encryption key for our database and sessions. Keep this very secure.
# If you generate a new one all existing data must be considered LOST.
# Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it
APP_KEY=SomeRandomStringOf32CharsExactly \
# This variable must match your installation's external address but keep in mind that
# it's only used on the command line as a fallback value.
APP_URL=http://localhost \
# Turn this to true if you want your app to react like a demo.
# The Demo mode reset the app content every hours and set a generic demo user.
IS_DEMO_APP=false \
# The log channel defines where your log entries go to.
# 'daily' is the default logging mode giving you 5 daily rotated log files in /storage/logs/.
# Several other options exist. You can use 'single' for one big fat error log (not recommended).
# Also available are 'syslog', 'errorlog' and 'stdout' which will log to the system itself.
LOG_CHANNEL=daily \
# Log level. You can set this from least severe to most severe:
# debug, info, notice, warning, error, critical, alert, emergency
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
# nothing will get logged, ever.
APP_LOG_LEVEL=notice \
# Database config & credentials
# DB_CONNECTION can be mysql
DB_CONNECTION=sqlite \
DB_DATABASE="/srv/database/database.sqlite" \
# if you want to use MySQL:
DB_HOST=127.0.0.1 \
DB_PORT=3306 \
DB_USERNAME=homestead \
DB_PASSWORD=secret \
# If you're looking for performance improvements, you could install memcached.
CACHE_DRIVER=file \
SESSION_DRIVER=file \
# Mail settings
# Refer your email provider documentation to configure your mail settings
# Set a value for every available setting to avoid issue
MAIL_DRIVER=log \
MAIL_HOST=smtp.mailtrap.io \
MAIL_PORT=2525 \
[email protected] \
MAIL_USERNAME=null \
MAIL_PASSWORD=null \
MAIL_ENCRYPTION=null \
MAIL_FROM_NAME=null \
MAIL_FROM_ADDRESS=null \
# Leave the following configuration vars as is.
# Unless you like to tinker and know what you're doing.
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

ARG VERSION=unknown
ARG CREATED="an unknown date"
ARG COMMIT=unknown
ENV COMMIT=${COMMIT}
LABEL \
org.opencontainers.image.authors="https://github.com/Bubka" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.created=$CREATED \
org.opencontainers.image.revision=$COMMIT \
org.opencontainers.image.url="https://github.com/Bubka/2FAuth" \
org.opencontainers.image.documentation="https://hub.docker.com/r/2fauth/2fauth" \
org.opencontainers.image.source="https://github.com/Bubka/2FAuth" \
org.opencontainers.image.title="2fauth" \
org.opencontainers.image.description="A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 2FAuth

![https://travis-ci.com/github/Bubka/2FAuth](https://img.shields.io/travis/com/bubka/2fauth?style=flat-square)
[![Docker build status](https://github.com/Bubka/2fauth/actions/workflows/ci.yml/badge.svg)](https://github.com/Bubka/2fauth/actions/workflows/ci.yml)
![https://codecov.io/gh/Bubka/2FAuth](https://img.shields.io/codecov/c/github/Bubka/2FAuth?style=flat-square)
![https://github.com/Bubka/2FAuth/blob/master/LICENSE](https://img.shields.io/github/license/Bubka/2FAuth.svg?style=flat-square)

Expand All @@ -10,6 +11,8 @@ A web app to manage your Two-Factor Authentication (2FA) accounts and generate t

[**2FAuth Demo**](https://demo.2fauth.app/)

[**Use it with Docker**](docker)

Credentials (login - password) : *[email protected]* - *demo*

## Purpose
Expand Down
Loading