diff --git a/.env.example b/.env.example index 41acc57..69dd81e 100644 --- a/.env.example +++ b/.env.example @@ -1,10 +1,26 @@ PROJECT_ROOT="" -CONTAINER_NAME="pf" DOMAIN="" # Emails from Let's Encrypt about your certificate will go here LE_EMAIL="" APP_PASSWORD="" +MYSQL_HOST="mariadb" +MYSQL_PORT="3306" +MYSQL_USER="root" MYSQL_PASSWORD="" +MYSQL_PF_DB_NAME="pathfinder" +MYSQL_UNIVERSE_DB_NAME="eve_universe" +MYSQL_CCP_DB_NAME="eve_lifeblood_min" +REDIS_HOST="redis" +REDIS_PORT="6379" CCP_SSO_CLIENT_ID="" CCP_SSO_SECRET_KEY="" -CCP_ESI_SCOPES="esi-location.read_online.v1,esi-location.read_location.v1,esi-location.read_ship_type.v1,esi-ui.write_waypoint.v1,esi-ui.open_window.v1,esi-universe.read_structures.v1,esi-corporations.read_corporation_membership.v1,esi-clones.read_clones.v1,esi-characters.read_corporation_roles.v1,esi-search.search_structures.v1" +CCP_ESI_SCOPES="esi-location.read_online.v1,esi-location.read_location.v1,esi-location.read_ship_type.v1,esi-ui.write_waypoint.v1,esi-ui.open_window.v1,esi-universe.read_structures.v1,esi-corporations.read_corporation_membership.v1,esi-clones.read_clones.v1,esi-characters.read_corporation_roles.v1" +PATHFINDER_SOCKET_HOST="pathfinder-socket" +PATHFINDER_SOCKET_PORT="5555" +SMTP_HOST="" +SMTP_PORT="" +SMTP_SCHEME="" +SMTP_USER="" +SMTP_PASS="" +SMTP_FROM="" +SMTP_ERROR="" diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml new file mode 100644 index 0000000..87bb4e8 --- /dev/null +++ b/.github/workflows/publish-docker.yaml @@ -0,0 +1,48 @@ +name: Create and publish a Docker image + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME_OWNER: ${{ github.repository_owner }} + +jobs: + build-and-publish: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - dockerfile: ./pathfinder.Dockerfile + image_name: pathfinder + - dockerfile: ./pf-websocket.Dockerfile + image_name: pf-websocket + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_OWNER }}/${{ matrix.image_name }} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: ${{ matrix.dockerfile }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 81da41d..c6751fa 100644 --- a/README.md +++ b/README.md @@ -47,15 +47,31 @@ A fork of techfreak's [Pathfinder-container](https://gitlab.com/techfreak/pathfi 1. **Create a *.env* file (copy .env.example) and make sure every config option has an entry.** ```shell - PROJECT_ROOT="" # The path of the cloned repo + PROJECT_ROOT="" # The path of the cloned repo CONTAINER_NAME="pf" # docker container name prefix DOMAIN="" # The domain you will be using APP_PASSWORD="" # Password for /setup - MYSQL_PASSWORD="" # Mysql Password + MYSQL_HOST="mariadb" # mysql host + MYSQL_PORT="3306" # default mysql port + MYSQL_USER="root" # mysql root user + MYSQL_PASSWORD="" # mysql Password CCP_SSO_CLIENT_ID="" # Use the SSO tokens created in step 1 - CCP_SSO_SECRET_KEY="" + CCP_SSO_SECRET_KEY="" CCP_ESI_SCOPES="esi-location.read_online.v1,esi-location.read_location.v1,esi-location.read_ship_type.v1,esi-ui.write_waypoint.v1,esi-ui.open_window.v1,esi-universe.read_structures.v1,esi-corporations.read_corporation_membership.v1,esi-clones.read_clones.v1,esi-characters.read_corporation_roles.v1" - + MYSQL_PF_DB_NAME="pathfinder" # mysql pathfinder table name + MYSQL_UNIVERSE_DB_NAME="eve_universe" + MYSQL_CCP_DB_NAME="eve_lifeblood_min" + REDIS_HOST="redis" # redis host + REDIS_PORT="6379" # default redis port + PATHFINDER_SOCKET_HOST="pathfinder-socket" # domain of the websocket container, relative to the main pf container + PATHFINDER_SOCKET_PORT="5555" # default tcp socket port + SMTP_HOST="" + SMTP_PORT="" + SMTP_SCHEME="" + SMTP_USER="" + SMTP_PASS="" + SMTP_FROM="" + SMTP_ERROR="" > The `PROJECT_ROOT` key is the *absolute* path to the project directory, ie if you have clone it to /app/pathfinder-containers, this is the value you should enter. If you're unsure of the absolute path, you can use the command `pwd` to get the full absolute path of the current directory. 1. **Edit the *config/pathfinder/pathfinder.ini*** to your liking diff --git a/config/pathfinder/config.ini b/config/pathfinder/config.ini index 6bc858e..3c11fcf 100644 --- a/config/pathfinder/config.ini +++ b/config/pathfinder/config.ini @@ -53,7 +53,7 @@ SEED = {{ md5(@SERVER.SERVER_NAME) }} ; - Cache data is stored on disc ; redis=[SERVER] ; - Cache data is stored in Redis. redis=[host]:[port]:[db]:[auth] (e.g. redis=localhost:6379:1:myPass) -CACHE = redis=${CONTAINER_NAME}-redis:6379 +CACHE = redis=${REDIS_HOST}:${REDIS_PORT} ; Cache backend for API data ; This sets the cache backend for API response data and other temp data relates to API requests. diff --git a/docker-compose.yml b/docker-compose.yml index 45ba581..63e4159 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,18 +5,16 @@ services: image: bianjp/mariadb-alpine:latest environment: MYSQL_ROOT_PASSWORD: $MYSQL_PASSWORD - container_name: "$CONTAINER_NAME-db" networks: pf: aliases: - - "${CONTAINER_NAME}db" + - "$MYSQL_HOST" volumes: - db_data:/var/lib/mysql - $PROJECT_ROOT/pathfinder/export/sql/eve_universe.sql.zip:/eve_universe.sql.zip restart: always pf-redis: image: redis:6.2.5-alpine3.14 - container_name: "$CONTAINER_NAME-redis" command: ["redis-server", "--appendonly", "yes"] hostname: redis volumes: @@ -24,27 +22,26 @@ services: networks: pf: aliases: - - "$CONTAINER_NAME-redis" + - "$REDIS_HOST" logging: driver: none restart: always pf-socket: - image: composer:composer@sha256:d374b2e1f715621e9d9929575d6b35b11cf4a6dc237d4a08f2e6d1611f534675 - container_name: "$CONTAINER_NAME-socket" - command: ["sh","-c","composer install && php cmd.php --tcpHost 0.0.0.0"] + build: + context: '.' + dockerfile: '$PROJECT_ROOT/pf-websocket.Dockerfile' + command: ["--tcpHost", "0.0.0.0"] hostname: socket - volumes: - - ${PROJECT_ROOT}/websocket:/app - - ${PROJECT_ROOT}/logs:/var/www/html/pathfinder/history/map networks: pf: aliases: - - "$CONTAINER_NAME-socket" + - "$PATHFINDER_SOCKET_HOST" restart: always pf: - container_name: ${CONTAINER_NAME} hostname: "pathfinder" - build: '.' + build: + context: '.' + dockerfile: '$PROJECT_ROOT//pathfinder.Dockerfile' env_file: - .env labels: diff --git a/Dockerfile b/pathfinder.Dockerfile similarity index 83% rename from Dockerfile rename to pathfinder.Dockerfile index 2020534..51c3281 100644 --- a/Dockerfile +++ b/pathfinder.Dockerfile @@ -2,9 +2,11 @@ FROM php:7.2.11-fpm-alpine3.7 as build RUN apk update \ && apk add --no-cache libpng-dev zeromq-dev git \ - $PHPIZE_DEPS \ - && docker-php-ext-install gd && docker-php-ext-install pdo_mysql && pecl install redis && docker-php-ext-enable redis && pecl install channel://pecl.php.net/zmq-1.1.3 && docker-php-ext-enable zmq \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer + $PHPIZE_DEPS \ + && docker-php-ext-install gd && docker-php-ext-install pdo_mysql && \ + pecl install redis && docker-php-ext-enable redis && \ + pecl install channel://pecl.php.net/zmq-1.1.3 && docker-php-ext-enable zmq && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer COPY pathfinder /app WORKDIR /app @@ -39,7 +41,7 @@ COPY static/entrypoint.sh / WORKDIR /var/www/html COPY --chown=nobody --from=build /app pathfinder -RUN chmod 0766 pathfinder/logs pathfinder/tmp/ && rm index.php && touch /etc/nginx/.setup_pass && chmod +x /entrypoint.sh +RUN chmod 0766 pathfinder/logs pathfinder/tmp/ && rm index.php && touch /etc/nginx/.setup_pass && chmod +x /entrypoint.sh COPY static/pathfinder/routes.ini /var/www/html/pathfinder/app/ COPY static/pathfinder/environment.ini /var/www/html/pathfinder/app/templateEnvironment.ini diff --git a/pf-websocket.Dockerfile b/pf-websocket.Dockerfile new file mode 100644 index 0000000..58eed9b --- /dev/null +++ b/pf-websocket.Dockerfile @@ -0,0 +1,7 @@ +FROM composer:2.3.10 +COPY websocket /app +WORKDIR /app + +RUN composer install + +ENTRYPOINT ["/usr/local/bin/php", "cmd.php"] diff --git a/static/entrypoint.sh b/static/entrypoint.sh index f627dfd..335605a 100644 --- a/static/entrypoint.sh +++ b/static/entrypoint.sh @@ -2,7 +2,7 @@ set -e crontab /var/crontab.txt envsubst '$DOMAIN' /etc/nginx/sites_enabled/site.conf -envsubst '$CONTAINER_NAME' /etc/nginx/nginx.conf +envsubst '$PATHFINDER_SOCKET_HOST' /etc/nginx/nginx.conf envsubst /var/www/html/pathfinder/app/environment.ini envsubst /var/www/html/pathfinder/app/config.ini envsubst /etc/php7/conf.d/zzz_custom.ini diff --git a/static/nginx/nginx.conf b/static/nginx/nginx.conf index 3d6c056..333a3d4 100755 --- a/static/nginx/nginx.conf +++ b/static/nginx/nginx.conf @@ -165,10 +165,10 @@ http { } upstream websocket { - server ${CONTAINER_NAME}-socket:8020; + server ${PATHFINDER_SOCKET_HOST}:8020; } - + # Default log file @@ -235,7 +235,7 @@ http { # a specific directory, or on an individual server{} level. gzip_static off; - proxy_buffers 16 16k; + proxy_buffers 16 16k; proxy_buffer_size 16k; # Include files in the sites-enabled folder. server{} configuration files should be diff --git a/static/pathfinder/environment.ini b/static/pathfinder/environment.ini index 64628f6..5f4a967 100644 --- a/static/pathfinder/environment.ini +++ b/static/pathfinder/environment.ini @@ -15,23 +15,23 @@ URL = {{@SCHEME}}://$DOMAIN ; level of debug/error stack trace DEBUG = 0 ; Pathfinder database -DB_PF_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname= -DB_PF_NAME = pf -DB_PF_USER = root +DB_PF_DNS = mysql:host=${MYSQL_HOST};port=${MYSQL_PORT};dbname= +DB_PF_NAME = $MYSQL_PF_DB_NAME +DB_PF_USER = $MYSQL_USER DB_PF_PASS = $MYSQL_PASSWORD -; Universe data (New Eden) cache DB for ESI API respons -DB_UNIVERSE_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname= -DB_UNIVERSE_NAME = eve_universe -DB_UNIVERSE_USER = root +; Universe data (New Eden) cache DB for ESI API response +DB_UNIVERSE_DNS = mysql:host=${MYSQL_HOST};port=${MYSQL_PORT};dbname= +DB_UNIVERSE_NAME = $MYSQL_UNIVERSE_DB_NAME +DB_UNIVERSE_USER = $MYSQL_USER DB_UNIVERSE_PASS = $MYSQL_PASSWORD ; EVE-Online CCP Database export -DB_CCP_DNS = mysql:host=${CONTAINER_NAME}db;port=3306;dbname= -DB_CCP_NAME = eve_lifeblood_min -DB_CCP_USER = root -DB_CCP_PASS = $MYSQL_PASSWORD +DB_CCP_DNS = mysql:host=${MYSQL_HOST};port=${MYSQL_PORT};dbname= +DB_CCP_NAME = $MYSQL_CCP_DB_NAME +DB_CCP_USER = $MYSQL_USER +DB_CCP_PASS = $MYSQL_PASSWORD ; CCP SSO CCP_SSO_URL = https://login.eveonline.com @@ -43,19 +43,19 @@ CCP_SSO_DOWNTIME = 11:00 ; CCP ESI API CCP_ESI_URL = https://esi.evetech.net CCP_ESI_DATASOURCE = tranquility -CCP_ESI_SCOPES = $CCP_ESI_SCOPES +CCP_ESI_SCOPES = $CCP_ESI_SCOPES CCP_ESI_SCOPES_ADMIN = ; SMTP settings (optional) -SMTP_HOST = localhost -SMTP_PORT = 25 -SMTP_SCHEME = TLS -SMTP_USER = -SMTP_PASS = +SMTP_HOST = $SMTP_HOST +SMTP_PORT = $SMTP_PORT +SMTP_SCHEME = $SMTP_SCHEME +SMTP_USER = $SMTP_USER +SMTP_PASS = $SMTP_PASS -SMTP_FROM = registration@pathfinder-w.space -SMTP_ERROR = admin@pathfinder-w.space +SMTP_FROM = $SMTP_FROM +SMTP_ERROR = $SMTP_EMAIL ; TCP Socket configuration (optional) (advanced) -SOCKET_HOST = ${CONTAINER_NAME}-socket -SOCKET_PORT = 5555 +SOCKET_HOST = $PATHFINDER_SOCKET_HOST +SOCKET_PORT = $PATHFINDER_SOCKET_PORT diff --git a/static/php/php.ini b/static/php/php.ini index 0b403a3..e17d3c2 100755 --- a/static/php/php.ini +++ b/static/php/php.ini @@ -9,7 +9,7 @@ fastcgi.impersonate=1 fastcgi.logging=0 request_terminate_timeout = 300 session.save_handler = redis -session.save_path = "tcp://${CONTAINER_NAME}-redis:6379" +session.save_path = "tcp://${REDIS_HOST}:${REDIS_PORT}" [Date] date.timezone="UTC"