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

Docker GitHub workflow #4

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
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
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 }}
28 changes: 14 additions & 14 deletions docker/development/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
services:
# TODO: add wings and pterodactyl
controlpanel_standalone:
ctrlpanel_development:
build:
context: ../../
dockerfile: ./docker/standalone/Dockerfile
container_name: controlpanel_development
restart: on-failure
container_name: ctrlpanel_development
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- '../..:/var/www/html:rw'
- './nginx_config:/etc/nginx/conf.d/:rw'
networks:
- laravel
- ctrlpanel

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

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: controlpanel_phpmyadmin
container_name: ctrlpanel_phpmyadmin
depends_on:
- mysql
ports:
- '8080:80'
environment:
- PMA_HOST=controlpanel_mysql
- PMA_HOST=ctrlpanel_mysql
- PMA_USER=root
- PMA_PASSWORD=root
- PMA_ARBITRARY=1
networks:
- laravel
- ctrlpanel

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

networks:
laravel:
ctrlpanel:
12 changes: 10 additions & 2 deletions docker/standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ If you're using a different operating system, you can follow the official 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 -v /path/to/nginx_config:/etc/nginx/conf.d/ ctrlpanel/ctrlpanel
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 Docker Hub and run it.
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.

Expand Down
67 changes: 57 additions & 10 deletions docker/standalone/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@
version: '3'

services:
controlpanel_standalone:
build:
context: ../../
dockerfile: ./docker/standalone/Dockerfile
container_name: controlpanel_standalone
restart: on-failure
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:
- './website_files:/var/www/html:rw' # change it
- './nginx_config:/etc/nginx/conf.d/:rw' # change it
- './logs:/var/www/html/storage/logs:w'
- './env_file:/var/www/html/.env'
Comment on lines -14 to +13
Copy link
Owner

@S0ly S0ly Jun 7, 2024

Choose a reason for hiding this comment

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

unfortunately this will not work it need to be like the dev docker, ctrlpanel is not really made to be inside a docker and is executing some command like composer :( and some people have themes and addons
so you need the panel code to always be saved, there will be an update script dont worry :)
so you need website and nginx to be saved as volume

Copy link
Author

Choose a reason for hiding this comment

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

executing composer works fine. it installs composer just as it would for a normal install upon container start. i dont see an issue there. for themes and addons i would just need to know in which folders they would be saved and they could be exposed just like the logs.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah having composer install at each start is not very great, and most people use theme and addons which are not supported by default they change files of the panel any file

Copy link
Owner

Choose a reason for hiding this comment

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

I have exactly the same issue whit the pterodactyl panel where I need the file for my modified ptero and each time I start it it’s re uploading default configuration of eggs and it’s very annoying

Copy link
Author

Choose a reason for hiding this comment

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

It is not running composer install on every container startup.
And for themes and addons, as i said, if you tell me what directories i need to be exposed, i can add a bind mount for them.

Copy link
Author

Choose a reason for hiding this comment

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

Updated it, please review.

Copy link
Owner

Choose a reason for hiding this comment

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

the current standalone will still not work whit addons and modification, adding by default the project files would be better :)

Copy link
Author

Choose a reason for hiding this comment

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

I do not agree with that. I changed it so the project files are exposed by default. Here a couple reasons:

  • You yourself told me a few days ago: the lesser permission the better -> the normal user doesn't need access to the project files at all
  • It might confuse users since they most likely wont need this anyways.
  • It's a weird a bad practice

So i still think having by default the project files NOT exposed would be the much more appropriate way. And the people still got the option to safely expose them at any time later if they need to, without breaking anything. Exposing it by default just introduces different problems.

Copy link
Owner

Choose a reason for hiding this comment

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

like I said ctrlpanel does not support addons correctly in the code and need the project files exposed for that, many people use a modified panel
and the default nginx config will be invalid since it need to be changed
these two things need to be exposed or available for exposing
but the nginx config is really needed (for SSL and things)
and it does not concern permission they are the same if there is a volume or not

Copy link
Author

Choose a reason for hiding this comment

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

If the nginx config of the docker container needs to be touched for addons, i guess thats alright. but it shouldnt be touched at all for any SSL/TLS stuff, that should absolutely be handled outside of the docker container by a reverse proxy and absolutely NOT by ctrlpanel itself ever!!!
if the docker compose comes with some reverse proxy, thats totally fine and legit. but the nginx inside of the docker container handling the stuff for the panel shouldn't do any of the TLS stuff!

I re-added the nginx config bind mount on your wish.

- './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:
9 changes: 6 additions & 3 deletions docker/standalone/scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ log_message() {
echo "$1"
}

# Check if project folder is empty.
if [ -z "$(ls -A /var/www/html)" ]; then
# Check if public folder is exists. If not, copy project.
if [ ! -d "/var/www/html/public" ]; then
log_message "Warning: project folder is empty. Copying default files..."
# Copy everything from /var/default to /var/www/html
cp -nr /var/default/. /var/www/html # Use -n to avoid overwriting existing files
chown -R laravel:laravel /var/www/html/
chmod -R 755 /var/www/html
chmod -R 755 /var/www/html/
fi

# Copy .env file for it to be available when starting the Docker container (to be able to bind-mount it to the host, instead of the entire project folder).
cp -n /var/default/.env.example /var/www/html/.env # Use -n to avoid overwriting existing files

# Check and copy default Nginx configuration if not exists
if [ ! -f "/etc/nginx/conf.d/default.conf" ]; then
log_message "Warning: Nginx configuration not found. Copying default configuration..."
Expand Down
1 change: 0 additions & 1 deletion public/install/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ function run_console(string $command, array $descriptors = null, string $cwd = n
if ($exit_code > 0) {
wh_log('command result: ' . $output, 'error');
throw new Exception("There was an error after running command `$command`", $exit_code);
return $output;
} else {
return $output;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/default/views/information/tos-content.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<ol>
<li>AGREEMENT TO TERMS</li>
<li>NTELLECTUAL PROPERTY RIGHTS</li>
<li>INTELLECTUAL PROPERTY RIGHTS</li>
<li>USER REPRESENTATIONS</li>
<li>USER REGISTRATION</li>
<li>PRODUCTS</li>
Expand Down