Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.gitignore
.dockerignore
Dockerfile
docker-compose.yml
Makefile
rendered/
vendor/
*.md
59 changes: 59 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Docker Environment for Odin

This document describes how to use the Docker environment set up for the Odin Celestial Planet Generator.

## Requirements

- Docker
- Docker Compose

## Getting Started

The project includes a Makefile with shortcuts for common operations:

```bash
# Show all available commands
make help

# Build the Docker image
make build

# Start the Docker container
make up

# Open a shell in the Docker container
make shell

# Run the tests
make test

# Generate an example planet image in the rendered directory
make example

# Stop the Docker container
make down

# Clean the rendered directory
make clean
```

## Configuration

- Images will be rendered in the `rendered` directory
- PHP with GD extension is configured in the Docker environment
- The environment variable `ODIN_RENDER_DIR` is set to `/app/rendered`

## Custom Usage

You can also use Docker Compose commands directly:

```bash
# Build and start the container
docker-compose up -d

# Execute a PHP script
docker-compose exec odin php your-script.php

# Stop and remove the container
docker-compose down
```
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM php:8.3-cli

# Install dependencies
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
git \
unzip \
&& rm -rf /var/lib/apt/lists/*

# Configure and install GD extension
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

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

# Set working directory
WORKDIR /app

# Copy project files
COPY . /app/

# Install dependencies
RUN composer --ignore-platform-req=ext-gd -W update symfony/filesystem phpspec/phpspec
RUN composer install --no-interaction --no-progress

# Create rendered directory
RUN mkdir -p /app/rendered

# Set permissions
RUN chmod -R 777 /app/rendered

# Set environment variable for rendered directory
ENV ODIN_RENDER_DIR=/app/rendered

CMD ["php", "-a"]
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.PHONY: build up down shell test clean help

# Colors for terminal output
YELLOW=\033[0;33m
GREEN=\033[0;32m
NC=\033[0m # No Color

help: ## Show this help
@echo ""
@echo "${YELLOW}Odin - The Celestial Planet Generator${NC}"
@echo "${YELLOW}====================================${NC}"
@echo ""
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${GREEN}make %-15s${NC} %s\n", $$1, $$2}'
@echo ""

build: ## Build the Docker image
docker compose build

up: ## Start the Docker container
docker compose up -d

down: ## Stop the Docker container
docker compose down

shell: ## Open a shell in the Docker container
docker compose exec odin bash

test: ## Run the tests
docker compose exec odin ./vendor/bin/phpspec run

example: ## Generate an example planet image
docker compose exec odin php examples.php

clean: ## Remove all generated images
rm -rf rendered/*
mkdir -p rendered
@echo "Rendered directory cleaned"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Odin aims to render randomly generated planets, moons and star fields as PNG ima
Here is an picture entirely generated by Odin:
![](example.png)

To discover how to use Odin, you can check the [examples](examples.php) files. Launch the `make example` command to generate various celestial objects in the `rendered` directory.

## Render a planet

```php
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"type": "library",
"description": "Odin - The Celestial Planet Generator",
"require": {
"php": ">=7.1.0",
"php": ">=8.3.0",
"ext-gd": "@stable",
"a1essandro/perlin-noise": "@stable",
"symfony/filesystem": "^4.1"
"symfony/filesystem": "^7.3"
},
"autoload": {
"psr-4": {
Expand All @@ -25,6 +25,6 @@
}
],
"require-dev": {
"phpspec/phpspec": "^5.1"
"phpspec/phpspec": "^7.6"
}
}
Loading