Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/docker #236

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
65 changes: 65 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Thumbs.db
.DS_Store
.idea

#
/.htaccess

# composer
composer.phar
vendor

# npm
node_modules
tools/ext

# cypress
cypress.env.json
cypress/e2e/2-advanced-examples
cypress/screenshots

# created by release.sh
releases
tmp

config.local.php
!docker/config.local.php

# all custom templates
templates/*
!templates/tibiacom
!templates/kathrine

# guild images
images/guilds/*
!images/guilds/default.gif

# editor images
images/editor/*
!images/editor/index.html

# gallery images
images/gallery/*
!images/gallery/index.html
!images/gallery/demon.jpg
!images/gallery/demon_thumb.gif

# cache
system/cache/*
!system/cache/index.html
!system/cache/twig/index.html
!system/cache/signatures/index.html
!system/cache/plugins/index.html
!system/cache/persistent/index.html

# logs
system/logs/*
!system/logs/index.html

# data
system/data/*
!system/data/index.html

# php sessions
system/php_sessions/*
!system/php_sessions/index.html
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ releases
tmp

config.local.php
!docker/config.local.php

# all custom templates
templates/*
Expand Down
40 changes: 40 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
web:
ports:
- 8001:80
build:
args:
user: www-data
uid: 33
context: ./
dockerfile: ./docker/Dockerfile
restart: unless-stopped
working_dir: /var/www/html
depends_on:
- db
#volumes:
# - ./:/var/www/html

db:
image: mysql:8.0
restart: unless-stopped # always?
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_DATABASE: myaac
#MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: myaac
MYSQL_USER: myaac
ports:
- 8003:3306
volumes:
- ./docker/tfs_schema.sql:/docker-entrypoint-initdb.d/tfs_schema.sql
- db:/var/lib/mysql

phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8002:80

volumes:
db:
56 changes: 56 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM php:8.2-apache
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using multi-stage build to avoid building all of this each time and why not nginx?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any advantages of using nginx on single host for development purposes (this docker image is not intended for production).

About multi-stage build: thanks, didn't knew about that one. Will dive into it, and will see what can be done.


ARG APCU_VERSION=5.1.22

# Arguments defined in docker-compose.yml
ARG user
ARG uid

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
nano \
vim

RUN apt-get install -y nodejs npm

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN docker-php-ext-install pdo pdo_mysql gd zip opcache
RUN docker-php-ext-configure opcache --enable-opcache
RUN pecl install apcu-${APCU_VERSION} && docker-php-ext-enable apcu

# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Create system user to run Composer Commands
#RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user

RUN chown -R www-data.www-data /var/www

USER $user

WORKDIR /home/$user
RUN git clone https://github.com/otland/forgottenserver.git

COPY --chown=www-data:www-data docker/config.lua /home/$user/forgottenserver
COPY --chown=www-data:www-data docker/config.local.php /var/www/html

#WORKDIR /home/$user/forgottenserver

WORKDIR /var/www/html

COPY --chown=www-data:www-data . .
RUN composer install
RUN npm install
4 changes: 4 additions & 0 deletions docker/config.local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$config['installed'] = false;
$config['server_path'] = '/home/www-data/forgottenserver';
$config['install_ignore_ip_check'] = true;
12 changes: 12 additions & 0 deletions docker/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
serverName = "Forgotten"
mysqlHost = "db"
mysqlUser = "myaac"
mysqlPass = "myaac"
mysqlDatabase = "myaac"
mysqlPort = 3306
mysqlSock = ""

ip = "192.168.176.1"
statusPort = 7171
statusTimeout = 2000

Loading
Loading