Skip to content
Merged
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
39 changes: 31 additions & 8 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# .dockerignore
.git
.env
.gitattributes
.github
.idea
.vscode
node_modules
vendor
storage/logs
storage/framework/sessions
storage/framework/cache
storage/framework/views
docker
.devcontainer
.editorconfig
.env
.env.example
.styleci.yml
.phpunit.result.cache
/node_modules
/vendor
/storage/app
/storage/framework
/storage/logs
/public/storage
/tests
/docs
README.md
CHANGELOG.md
CONTRIBUTING.md
LICENSE
phpunit.xml
docker-compose.yml
compose.dev.yml
Dockerfile.dev
docker/development
docker/common
render.yaml
!docker/production
!docker/production/nginx/nginx.conf
!docker/production/start.sh
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dockerfile
# Builder stage
FROM public.ecr.aws/composer/composer:2 AS builder
WORKDIR /app
COPY . .
RUN composer install --no-dev --no-interaction --optimize-autoloader

# Production stage
FROM public.ecr.aws/php/php:8.2-fpm-alpine
WORKDIR /var/www

# Install dependencies
RUN apk add --no-cache nginx libpq

# Copy nginx configuration
COPY docker/production/nginx/nginx.conf /etc/nginx/nginx.conf

# Copy application files from builder stage
COPY --from=builder /app .

# Copy start script
COPY docker/production/start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh

# Set permissions
RUN chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache

# Expose port 80
EXPOSE 80

# Start supervisord
CMD ["/usr/local/bin/start.sh"]
52 changes: 52 additions & 0 deletions docker/production/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 768;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;

server {
listen 80;
server_name _;

root /var/www/public;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}
}
7 changes: 7 additions & 0 deletions docker/production/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Start PHP-FPM
php-fpm &

# Start Nginx
nginx -g "daemon off;"
9 changes: 5 additions & 4 deletions docs/RENDER.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ This project is configured for automatic deployment to the [Render](https://rend

## How It Works

This repository contains a `render.yaml` file that uses Render's "Blueprint" feature. This file tells Render everything it needs to know to deploy the application, including:
This repository contains a `render.yaml` file in the root directory that uses Render's "Blueprint" feature. This file tells Render everything it needs to know to deploy the application, including:

- A **web service** running the Laravel application.
- A **web service** running the Laravel application. This service is built using the `Dockerfile` in the root of the repository.
- A **PostgreSQL database** for storing data.

When you push changes to the `main` branch on GitHub, Render will automatically:

1. Detect the changes.
2. Build the application using the `buildCommand` defined in `render.yaml`. This includes installing dependencies and running database migrations.
3. Deploy the new version of the application.
2. Build the Docker image for the application.
3. Run the `buildCommand` defined in `render.yaml` to execute database migrations (`php artisan migrate --force`).
4. Deploy the new version of the application.

## Initial Setup on Render

Expand Down
49 changes: 49 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
services:
- type: web
name: ote
env: docker
repo: https://github.com/attogram/ote
region: oregon
plan: free
healthCheckPath: /
buildCommand: 'php artisan migrate --force'
envVars:
- key: DB_CONNECTION
value: pgsql
- key: DB_HOST
fromService:
type: psql
name: ote-db
property: host
- key: DB_PORT
fromService:
type: psql
name: ote-db
property: port
- key: DB_DATABASE
fromService:
type: psql
name: ote-db
property: database
- key: DB_USERNAME
fromService:
type: psql
name: ote-db
property: user
- key: DB_PASSWORD
fromService:
type: psql
name: ote-db
property: password
- key: APP_KEY
generateValue: true
- key: APP_URL
fromService:
type: web
name: ote
property: url
- type: psql
name: ote-db
region: oregon
plan: free
version: "14"