From 1cb0a32aeb4d25d25a89cc4fc6605ea3500ea77c Mon Sep 17 00:00:00 2001 From: butschster Date: Tue, 8 Aug 2023 00:28:53 +0400 Subject: [PATCH] Adds docker base image build --- .github/FUNDING.yml | 3 +++ .github/workflows/docker-image.yml | 42 ++++++++++++++++++++++++++++++ .idea/.gitignore | 8 ++++++ .idea/docker.iml | 8 ++++++ .idea/modules.xml | 8 ++++++ .idea/php.xml | 19 ++++++++++++++ .idea/vcs.xml | 6 +++++ Dockerfile | 33 +++++++++++++++++++++++ nginx/default.conf | 22 ++++++++++++++++ nginx/nginx.conf | 30 +++++++++++++++++++++ 10 files changed, 179 insertions(+) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/docker-image.yml create mode 100644 .idea/.gitignore create mode 100644 .idea/docker.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 Dockerfile create mode 100644 nginx/default.conf create mode 100644 nginx/nginx.conf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a26fed8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +patreon: butschster diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..4dcd84c --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,42 @@ +name: Docker Image CI + +on: + release: + types: + - created + +jobs: + build-release: + if: "!github.event.release.prerelease" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + with: + fallback: v0.1 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ secrets.GHCR_LOGIN }} + password: ${{ secrets.GHCR_PASSWORD }} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: ./ + platforms: linux/amd64,linux/arm64 + file: ./docker/Dockerfile + push: true + tags: + ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.previoustag.outputs.tag }} diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/docker.iml b/.idea/docker.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/docker.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..947f6e8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..f324872 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbccd9c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM php:8.1.3-cli-alpine3.15 + +RUN apk add --no-cache \ + curl \ + libcurl \ + wget \ + libzip-dev \ + libmcrypt-dev \ + libxslt-dev \ + libxml2-dev \ + icu-dev \ + zip + +RUN docker-php-ext-install \ + opcache \ + zip \ + xsl \ + dom \ + exif \ + intl \ + pcntl \ + bcmath \ + sockets + +RUN apk add --no-cache nginx +RUN cp docker/nginx/nginx.conf /etc/nginx/nginx.conf +RUN [ -d /etc/nginx/conf.d ] || mkdir /etc/nginx/conf.d +RUN cp docker/nginx/default.conf /etc/nginx/conf.d/default.conf + +RUN curl -s https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin/ --filename=composer + +RUN docker-php-source delete \ + && apk del ${BUILD_DEPENDS} \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..61ba360 --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,22 @@ +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +server { + listen 8000; + + server_name _; + + location /connection { + proxy_pass http://127.0.0.1:8089/connection; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + } + + location / { + proxy_pass http://127.0.0.1:8082; + } +} diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..c0ca09b --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,30 @@ +daemon off; +user nginx; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /dev/stdout main; + + # fix for very long server names + server_names_hash_bucket_size 128; + + sendfile on; + # tcp_nopush on; + + keepalive_timeout 65; + + # gzip on; + + include /etc/nginx/conf.d/*.conf; +}