Skip to content

Commit

Permalink
merge: pull request #4 from jameskitt616/docker-github-workflow
Browse files Browse the repository at this point in the history
Docker GitHub workflow
  • Loading branch information
S0ly committed Jun 9, 2024
2 parents 1c1eede + bb9bc29 commit 81fe738
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 31 deletions.
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'
- './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

0 comments on commit 81fe738

Please sign in to comment.