From 076b2d833f003a3bf933fe3535e78ba098f55200 Mon Sep 17 00:00:00 2001 From: Marcel Hernandez Date: Sat, 15 Jun 2024 22:53:18 +0200 Subject: [PATCH] publish Docker image --- .github/workflows/ci.yml | 26 ++++++++++++++++++++--- Dockerfile | 45 ++++++++++++++++++++++++++++++++++++++++ src/DI/Faucet.php | 2 +- 3 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8cd1fc9..19c8693 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ -name: CI +name: Continuous Integration on: push jobs: - run: - name: Continuous Integration + run-tests: + name: Run linter and tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -20,3 +20,23 @@ jobs: - run: composer test - if: always() run: docker compose down -v + build-image: + name: Build Docker image + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' + needs: + - run-tests + steps: + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + username: 1maa + password: ${{ secrets.DOCKER_HUB_PASS }} + - run: ls -la + - uses: docker/build-push-action@v5 + with: + cache-from: type=registry,ref=1maa/bbo-faucet:latest + cache-to: type=inline + context: . + push: true + tags: 1maa/bbo-faucet:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..91d6bc8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +FROM 1maa/php-dev:8.3 AS builder + +WORKDIR /tmp/faucet + +COPY bin bin +COPY src src +COPY views views +COPY web web +COPY composer.json . +COPY composer.lock . + +RUN composer install --no-dev --classmap-authoritative \ + && chown -R nobody:nobody /tmp/faucet + + +FROM 1maa/php:8.3 AS final + +ENV FAUCET_DEBUG=0 +ENV FAUCET_REDIS_ENDPOINT=redis:6379 +ENV FAUCET_REDIS_PREFIX="faucet:" +ENV FAUCET_BITCOIN_RPC_ENDPOINT="http://knots:18443" +ENV FAUCET_BITCOIN_RPC_USER=knots +ENV FAUCET_BITCOIN_RPC_PASS=knots +ENV FAUCET_NAME="Your Signet Faucet" +ENV FAUCET_MIN_ONE_TIME_BTC=0.001 +ENV FAUCET_MAX_ONE_TIME_BTC=5.0 +ENV FAUCET_USER_SESSION_TTL=3600 +ENV FAUCET_GLOBAL_SESSION_TTL=3600 +ENV FAUCET_USE_CAPTCHA=0 +ENV FAUCET_USE_BATCHING=0 +ENV FAUCET_FEE_RATE=0 +ENV FAUCET_USER_SESSION_MAX_BTC=20.0 +ENV FAUCET_GLOBAL_SESSION_MAX_BTC=150.0 + +ENV PHP_CLI_SERVER_WORKERS=8 + +COPY --from=builder /tmp/faucet /var/www/faucet + +WORKDIR /var/www/faucet + +USER nobody + +EXPOSE 8080 + +CMD ["php", "-d", "variables_order=EGPCS", "-S", "0.0.0.0:8080", "-t", "web"] diff --git a/src/DI/Faucet.php b/src/DI/Faucet.php index dd7bfda..0747a6b 100644 --- a/src/DI/Faucet.php +++ b/src/DI/Faucet.php @@ -23,7 +23,7 @@ final class Faucet implements ServiceProvider public function provide(Container $c): void { $c->set(Settings::class, static function (): Settings { - return new Settings($_SERVER); + return new Settings(array_merge($_SERVER, $_ENV)); }); $c->set(Twig::class, static function (ContainerInterface $c): Twig {