Skip to content

Commit

Permalink
Merge pull request #388 from 2zqa/add-dev-container
Browse files Browse the repository at this point in the history
Add dev container
  • Loading branch information
MaxKorlaar authored Oct 22, 2024
2 parents 4e1a96b + e1106bc commit 9a4483a
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/devcontainers/php:1-8.2-bookworm

# Install MariaDB client and other dependencies
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y mariadb-client libpng-dev libsodium-dev libwebp-dev libfreetype6-dev \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Install the PHP extensions we need
RUN docker-php-ext-configure gd \
--with-webp \
--with-freetype \
&& docker-php-ext-install gd mysqli pdo pdo_mysql sodium pcntl

# Enable redis extension
RUN pecl install redis && docker-php-ext-enable redis

# Configure Xdebug
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
# && echo "xdebug.start_with_request=trigger" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/xdebug.ini
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
{
"name": "Hypixel Signatures",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"forwardPorts": [
8000, // artisan serve
3306, // MySQL
9003 // Xdebug
],
"features": {
"ghcr.io/devcontainers/features/node:1": {
"pnpmVersion": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
"EditorConfig.EditorConfig"
]
}
}
}
42 changes: 42 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: mariadb:10.4
restart: unless-stopped
volumes:
- mariadb-data:/var/lib/mysql
network_mode: service:app
environment:
MYSQL_ROOT_PASSWORD: mariadb
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
# Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

redis:
image: redis:6
restart: unless-stopped
network_mode: service:app

# Add "forwardPorts": ["6379"] to **devcontainer.json** to forward Redis locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
mariadb-data:

0 comments on commit 9a4483a

Please sign in to comment.