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 12 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -24,6 +24,7 @@ releases
tmp

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

# all custom templates
templates/*
Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,41 @@
version: "1.0"
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:
53 changes: 53 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,53 @@
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

# 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
4 changes: 4 additions & 0 deletions docker/config.local.php
@@ -0,0 +1,4 @@
<?php
$config['installed'] = true;
$config['server_path'] = '/home/www-data/forgottenserver';
$config['install_ignore_ip_check'] = true;
12 changes: 12 additions & 0 deletions docker/config.lua
@@ -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