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

refactor: Docker #946

Open
wants to merge 77 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
312e53a
UPDATE: moved the developement docker into a developement folder
S0ly Apr 30, 2024
31c79cb
ADD: added a standalone docker
S0ly Apr 30, 2024
d10c7ac
REMOVED: binary for docker compose execution that where not used anymore
S0ly May 3, 2024
e340396
UPDATE: moved the building.md to the developement docker
S0ly May 3, 2024
96041d1
ADD: empty readme for the standalone docker
S0ly May 3, 2024
b52aeb2
UPDATE: made a working standalone docker whit a startup script for ea…
S0ly May 5, 2024
1403985
UPDATE: added more php dependency to the standalone dockerfile
S0ly May 7, 2024
469a814
UPDATE: made a better standalone docker compose
S0ly May 7, 2024
cb2ea11
UPDATE: made a better readme documentation for the standalone docker
S0ly May 7, 2024
5faea04
UPDATE: updated the standalone docker configuration
S0ly May 7, 2024
27cad91
FIX: standalone dockerfile now expose port 443
S0ly May 7, 2024
84417a9
UPDATE: added redis php extention to standalone docker
S0ly May 7, 2024
7d191ef
ADD: some permission to files
S0ly May 10, 2024
a7e5ab2
ADD: standalone docker Queue Worker
S0ly May 10, 2024
0683e2d
ADD: nano to the standalone docker
S0ly May 13, 2024
26a279f
FIX: tried to fix the standalone docker permissions
S0ly May 13, 2024
00397c1
FIX: logging config permissions
S0ly May 14, 2024
e3957bc
UPDATE: made a lot of change to the standalone dockerfile and script
S0ly May 14, 2024
dc1eca3
ADD: warning on top of the developement docker readme
S0ly May 14, 2024
5dc6aab
UPDATED: updated the development docker to use the standalone one whi…
S0ly May 28, 2024
984330a
UPDATE: updated the readme of the developement docker
S0ly May 28, 2024
4e0370b
Fix explode null parameter, Update dev docker compose file
jameskitt616 May 28, 2024
0596f7c
Update gitignore, Fix explode null parameter
jameskitt616 May 28, 2024
78479a0
Update dev compose.yml and gitignore
jameskitt616 May 28, 2024
299416d
Revert explode deprecation fix, move gitignore to apropriate folder
jameskitt616 May 28, 2024
1c1eede
Merge pull request #3 from jameskitt616/standalone-docker
S0ly May 28, 2024
3a7dc46
Add docker build workflow
jameskitt616 May 30, 2024
aa5820c
Add Dockerfile location to github workflow
jameskitt616 May 30, 2024
1968a97
Update standalone compose file
jameskitt616 May 30, 2024
93fb0b7
Change repository owner name
jameskitt616 May 30, 2024
9fef8ab
Update docker readme
jameskitt616 May 30, 2024
7a40c38
Update docker readme with redis instructions
jameskitt616 May 30, 2024
86de9ec
Update startup script
jameskitt616 May 30, 2024
47cdd8e
Add network to dev compose
jameskitt616 May 30, 2024
956e679
Set database name and user to defaults from installer
jameskitt616 May 30, 2024
e054cb9
Update permissions
jameskitt616 May 30, 2024
b3862a4
Try to determine if process is running within a docker container
jameskitt616 May 30, 2024
aadd164
Force conecole command without exec -a
jameskitt616 May 30, 2024
e564a38
Comment out everything in run_console command
jameskitt616 May 30, 2024
b8d6d59
Set different permissions
jameskitt616 May 30, 2024
c5ad334
Set different permissions
jameskitt616 May 30, 2024
92c1655
Open up permissions
jameskitt616 May 30, 2024
fec23ee
Revert stuff in functions.php
jameskitt616 May 30, 2024
786bac3
Reset permissions
jameskitt616 May 30, 2024
a2e0109
Update permissions in startup.sh
jameskitt616 May 30, 2024
76463c9
Add chown to startup.sh
jameskitt616 May 30, 2024
dffcb25
Add permissions to streamhandler
jameskitt616 May 30, 2024
0a3cc25
Revert StreamHandler permissions
jameskitt616 May 30, 2024
d6a01b6
Revert trustedpries
jameskitt616 May 30, 2024
f523ea6
Revert permissions in startup.sh
jameskitt616 May 30, 2024
c285f8f
Copy .env file in Dockerfile
jameskitt616 Jun 1, 2024
bdffb66
copy env file in startup script
jameskitt616 Jun 1, 2024
d6d5fd8
Copy .env.example from different dir
jameskitt616 Jun 1, 2024
318781f
Remove reverse parameter from copy single file
jameskitt616 Jun 2, 2024
bba697b
Create dir on startup script
jameskitt616 Jun 2, 2024
9cffe58
Run copy of project files every time
jameskitt616 Jun 2, 2024
a51ff57
ls project dirs to check if they are empty
jameskitt616 Jun 2, 2024
7c3d702
Show and set permissions for project folder
jameskitt616 Jun 2, 2024
4c833e2
Run copy project files anyways
jameskitt616 Jun 2, 2024
863299b
Attempt to fix startup script
jameskitt616 Jun 7, 2024
1cb03f5
Add logging to troubleshoot
jameskitt616 Jun 7, 2024
06a67fe
Check for public folder instead of if has contents
jameskitt616 Jun 7, 2024
9188c42
Remove unnecessary deletion of file
jameskitt616 Jun 7, 2024
ebe730b
Test if permissions are necessary
jameskitt616 Jun 7, 2024
9e6688d
Remove unnecessary permissions
jameskitt616 Jun 7, 2024
44c05b0
Update compose.yaml with only logs and env file
jameskitt616 Jun 7, 2024
33096fb
Rename controlpanel to ctrlpanel
jameskitt616 Jun 8, 2024
6a5f05e
Fix typo
jameskitt616 Jun 8, 2024
05dc11e
Update Readme and stanalone compose
jameskitt616 Jun 8, 2024
d210baa
Docker compose default add project files
jameskitt616 Jun 8, 2024
01ca75f
Fix typo
jameskitt616 Jun 8, 2024
a58aa10
Readd nginx config expose
jameskitt616 Jun 8, 2024
628f2c6
Update dev docker service name
jameskitt616 Jun 9, 2024
bb9bc29
Update standalone docker service name
jameskitt616 Jun 9, 2024
81fe738
merge: pull request #4 from jameskitt616/docker-github-workflow
S0ly Jun 9, 2024
06fca65
Merge branch 'development' into feature/standalone-docker
S0ly Jun 9, 2024
7fe5664
[Feat] Language additions
S0ly Jul 24, 2024
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
43 changes: 43 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Push Docker Image

on:
push:
tags:
- '*'

jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
file: docker/standalone/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 0 additions & 2 deletions bin/rebuild.sh

This file was deleted.

2 changes: 0 additions & 2 deletions bin/startdocker.sh

This file was deleted.

1 change: 0 additions & 1 deletion bin/stopdocker.sh

This file was deleted.

3 changes: 3 additions & 0 deletions config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'permission' => 0664,
],

'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
'permission' => 0664,
],

'slack' => [
Expand Down Expand Up @@ -116,6 +118,7 @@

'emergency' => [
'path' => storage_path('logs/laravel.log'),
'permission' => 0664,
],
],

Expand Down
3 changes: 3 additions & 0 deletions docker/development/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
!.gitignore
mysql
nginx_config
23 changes: 23 additions & 0 deletions docker/development/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 🐳 Docker Development Environment

This development environment utilizes standalone Docker with necessary tools pre-configured.

## Included Services
- Redis
- MySQL
- Tools like phpMyAdmin

## Not Included Services (for the moment)
- Pterodactyl
- Wings

Feel free to modify the Docker Compose file to remove any services you already have.

## Setting Up the Testing Environment

1. **Manual Setup:** As mentioned in the standalone Docker guide, you will need to manually set up some components.
2. **Custom Configuration:** Modify the CtrlPanel Docker Compose configuration to use your current project as a base. If you point it to an empty folder, it will clone the repository, and you won't see your changes immediately.

For detailed setup instructions, refer to the standalone Docker documentation.

⚠ Caution: These instructions have not been finished. Therefore, there may be inaccuracies, instability, or non-functional aspects. Proceed with care.
57 changes: 26 additions & 31 deletions docker/docker-compose.yml → docker/development/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
version: '3'

networks:
laravel:

services:
nginx:
# TODO: add wings and pterodactyl
ctrlpanel_development:
build:
context: ../
dockerfile: docker/nginx/Dockerfile
container_name: ctrlpanel_nginx
context: ../../
dockerfile: ./docker/standalone/Dockerfile
container_name: ctrlpanel_development
restart: unless-stopped
ports:
- 80:80
- "80:80"
- "443:443"
volumes:
- "../:/var/www/html"
depends_on:
- php
- mysql
- '../..:/var/www/html:rw'
- './nginx_config:/etc/nginx/conf.d/:rw'
networks:
- laravel
- ctrlpanel

mysql:
image: mysql
Expand All @@ -28,23 +24,13 @@ services:
- "3306:3306"
environment:
MYSQL_DATABASE: ctrlpanel
MYSQL_USER: ctrlpanel
MYSQL_USER: ctrlpaneluser
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
volumes:
- "mysql:/var/lib/mysql:delegated"
networks:
- laravel

php:
build:
context: ../
dockerfile: docker/php/Dockerfile
container_name: ctrlpanel_php
volumes:
- "../:/var/www/html"
- "./mysql:/var/lib/mysql:delegated"
networks:
- laravel
- ctrlpanel

phpmyadmin:
image: phpmyadmin/phpmyadmin
Expand All @@ -59,7 +45,16 @@ services:
- PMA_PASSWORD=root
- PMA_ARBITRARY=1
networks:
- laravel
- ctrlpanel

volumes:
mysql:
redis:
image: redis
container_name: ctrlpanel_redis
restart: unless-stopped
ports:
- "6379:6379"
networks:
- ctrlpanel

networks:
ctrlpanel:
10 changes: 0 additions & 10 deletions docker/nginx/Dockerfile

This file was deleted.

18 changes: 0 additions & 18 deletions docker/php/Dockerfile

This file was deleted.

62 changes: 62 additions & 0 deletions docker/standalone/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM php:8.1-fpm

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
nginx \
nano \
curl \
git \
libcurl4-openssl-dev \
libicu-dev \
libzip-dev \
libpng-dev \
&& rm -rf /var/lib/apt/lists/*

# Install PHP extensions
RUN pecl install redis \
&& docker-php-ext-enable redis \
&& docker-php-ext-install -j$(nproc) \
mysqli \
pdo \
pdo_mysql \
intl \
zip \
gd \
bcmath \
&& rm -rf /tmp/* /var/cache/*

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

# Create directory for application
RUN mkdir -p /var/default /var/www/html

# Create user and group for Laravel
RUN groupadd -g 1000 laravel \
&& useradd -u 1000 -g laravel -ms /bin/bash laravel \
&& chown -R laravel:laravel /var/default /var/www/html

# Copy application files
COPY --chown=laravel:laravel . /var/default

# Copy PHP-FPM configuration
COPY --chown=laravel:laravel ./docker/standalone/php/www.conf /usr/local/etc/php-fpm.d/

# Copy Nginx configuration
COPY --chown=laravel:laravel ./docker/standalone/nginx/nginx.conf /etc/nginx/nginx.conf
# Create directory for Nginx logs
RUN mkdir -p /var/log/nginx && chown -R laravel:laravel /var/log/nginx

# Expose ports
EXPOSE 80 443

# Copy startup script
COPY --chown=laravel:laravel ./docker/standalone/scripts/startup.sh /usr/local/bin/startup-script.sh
# Make startup script executable
RUN chmod +x /usr/local/bin/startup-script.sh

# Set the working directory
WORKDIR /var/www/html

# Start the startup script
CMD ["/usr/local/bin/startup-script.sh"]
34 changes: 34 additions & 0 deletions docker/standalone/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 🐳 Standalone Docker

The CtrlPanel standalone Docker enables users to run CtrlPanel easily with just a few clicks.

To run CtrlPanel standalone Docker, you need to have Docker installed on your machine. Some server operating systems like Unraid, TrueNAS, etc.. already have Docker installed, making it even easier to run CtrlPanel.
If you're using a different operating system, you can follow the official Docker installation guide [here](https://docs.docker.com/get-docker/).

Once you have Docker installed, you can run CtrlPanel standalone Docker by executing the following command:

Running as commandline command:

```bash
docker run -p 80:80 -p 443:443 -v /path/to/website_files:/var/www/html ghcr.io/ctrlpanel-gg/panel:latest
```

This command will run the latest CtrlPanel Docker image from GitHub Container Registry and run it.

Recommended way via Docker Compose:

1. Copy and configure your docker compose file to your needs `curl -L -o compose.yaml https://raw.githubusercontent.com/Ctrlpanel-gg/panel/blob/main/docker/standalone/compose.yaml`.
2. Create the env file in the same directory as the compose file `touch env_file`.
3. When installing you need to update the `env_file` file. Change those two variables to: `MEMCACHED_HOST=redis` and `REDIS_HOST=redis`, to use the Redis server which comes with the docker compose installation.

The control panel will be available at http://localhost/install and will be a completely fresh installation.

Note that while the container contains the full CtrlPanel installation, you will still need to perform the basic setup. You can find instructions for this [here](https://ctrlpanel.gg/docs/Installation/getting-started#basic-setup).

## 🏗️ Migrating from a previous bare metal installation

If you are migrating, from a previous bare metal installation, you can follow the instructions [here]() (Soon on documentation).

## 🧰 Creating your own Docker image

If you want to create your own Docker image, you can follow the instructions [here]() (Soon on documentation).
62 changes: 62 additions & 0 deletions docker/standalone/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
services:
ctrlpanel_standalone:
image: ghcr.io/ctrlpanel-gg/panel:latest
container_name: ctrlpanel_standalone
restart: unless-stopped
depends_on:
- redis
ports:
- "80:80"
- "443:443"
volumes:
- './logs:/var/www/html/storage/logs:w'
- './env_file:/var/www/html/.env'
- './website_files:/var/www/html:rw' # optionally remove this bind mount, it's not needed unless you want access to all project files, to modify the project with addons/plugins.
- './nginx_config:/etc/nginx/conf.d/:rw' # optionally remove this bind mount, it's not needed unless you want to modify the project with addons/plugins. (dangerous to edit)
networks:
- ctrlpanel

mysql:
image: mysql
container_name: ctrlpanel_mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ctrlpanel
MYSQL_USER: ctrlpaneluser
MYSQL_PASSWORD: root # change it
MYSQL_ROOT_PASSWORD: root # change it
volumes:
- "./mysql:/var/lib/mysql:delegated"
networks:
- ctrlpanel

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: ctrlpanel_phpmyadmin
restart: unless-stopped
depends_on:
- mysql
ports:
- '8080:80'
environment:
- PMA_HOST=ctrlpanel_mysql
- PMA_USER=root # change it
- PMA_PASSWORD=root # change it
- PMA_ARBITRARY=1
networks:
- ctrlpanel

redis:
image: redis
container_name: ctrlpanel_redis
restart: unless-stopped
ports:
- "6379:6379"
networks:
- ctrlpanel

networks:
ctrlpanel:
Loading