diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..10ac9a8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +tests +.git diff --git a/.env-example b/.env-example new file mode 100644 index 0000000..098bd89 --- /dev/null +++ b/.env-example @@ -0,0 +1,4 @@ +PORT=8080 +DOMAIN=example.com +ADMIN_USERNAME=username +ADMIN_PASSWORD=password diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..c03450a --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,19 @@ +name: Publish Docker image +on: + release: + types: [published] +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + repository: beyondcodegmbh/expose/expose-server + tag_with_ref: true diff --git a/.gitignore b/.gitignore index 2cffa58..075b932 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ expose.php database/expose.db .expose.php +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9cafe26 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM php:7.4-cli + +RUN apt-get update +RUN apt-get install -y git libzip-dev zip + +RUN docker-php-ext-install zip + +# Get latest Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +COPY . /src +WORKDIR /src + +# install the dependencies +RUN composer install -o --prefer-dist && chmod a+x expose + +ENV port=8080 +ENV domain=localhost +ENV username=username +ENV password=password +ENV exposeConfigPath=/src/config/expose.php + +CMD sed -i "s|username|${username}|g" ${exposeConfigPath} && sed -i "s|password|${password}|g" ${exposeConfigPath} && php expose serve ${domain} --port ${port} --validateAuthTokens diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ee8d126 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3.7" +services: + expose: + image: beyondcodegmbh/expose-server:latest + ports: + - 127.0.0.1:8080:${PORT} + environment: + port: ${PORT} + domain: ${DOMAIN} + username: ${ADMIN_USERNAME} + password: ${ADMIN_PASSWORD} + restart: always + volumes: + - ./database/expose.db:/root/.expose diff --git a/docs/server/starting-the-server.md b/docs/server/starting-the-server.md index 3e74c51..8fdfe67 100644 --- a/docs/server/starting-the-server.md +++ b/docs/server/starting-the-server.md @@ -122,4 +122,21 @@ return [ // ... ``` +## Running With Docker + +To run Expose with docker use the included `docker-compose.yaml`. Copy `.env-example` to `.env` and update the configuration. + +``` +PORT=8080 +DOMAIN=example.com +ADMIN_USERNAME=username +ADMIN_PASSWORD=password +``` + +After updating the environment variables you can start the server: + +```bash +docker-compose up -d +``` + Now that your basic expose server is running, let's take a look at how you can add SSL support.