Initial commit

This commit is contained in:
Christopher C. Wells 2021-04-24 09:46:52 -07:00
commit e33ca873d1
8 changed files with 257 additions and 0 deletions

62
.env.example Normal file
View File

@ -0,0 +1,62 @@
#
# Kcal application configuration.
#
APP_NAME=kcal
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://127.0.0.1/
APP_PORT=80
APP_PORT_SSL=443
APP_TIMEZONE=UTC
#
# Databases configuration.
#
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=kcal
DB_USERNAME=kcal
DB_PASSWORD=kcal
REDIS_HOST=redis
REDIS_PORT=6379
#
# Search configuration.
#
#SCOUT_DRIVER=null
#SCOUT_DRIVER=algolia
#ALGOLIA_APP_ID=
#ALGOLIA_SECRET=
SCOUT_DRIVER=elastic
ELASTIC_HOST=elasticsearch:9200
ELASTIC_PORT=9200
#
# Media (image storage) configuration.
#
MEDIA_DISK=local
#MEDIA_DISK=s3-public
#AWS_ACCESS_KEY_ID=
#AWS_SECRET_ACCESS_KEY=
#AWS_DEFAULT_REGION=
#AWS_BUCKET=
#
# Misc. drivers and configuration.
#
BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
SESSION_LIFETIME=120

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.DS_Store
.env
.idea
docker-compose.override.yml

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright 2021 Christopher Charbonneau Wells
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

46
README.md Normal file
View File

@ -0,0 +1,46 @@
# [kcal](https://github.com/kcal-app/kcal) for Docker!
[![Docker build status](https://img.shields.io/docker/cloud/build/kcalapp/kcal)](https://hub.docker.com/r/kcalapp/kcal/builds)
[![Docker version](https://img.shields.io/docker/v/kcalapp/kcal?sort=semver)](https://hub.docker.com/r/kcalapp/kcal/tags?page=1&ordering=last_updated)
[![Docker pulls](https://img.shields.io/docker/pulls/kcalapp/kcal)](https://hub.docker.com/r/kcalapp/kcal)
[![Docker image size](https://img.shields.io/docker/image-size/kcalapp/kcal)](https://hub.docker.com/r/kcalapp/kcal/tags?page=1&ordering=last_updated)
# :construction: **WORK IN PROGRESS** :construction:
This is a template repository for running [kcal](https://github.com/kcal-app/kcal)
with Docker Compose. Visit the main [kcal](https://github.com/kcal-app/kcal) repository
for more information about the application.
## 1. Clone
Clone this repo.
git clone https://github.com/kcal-app/kcal-docker.git
## 2. Create `.env` file.
cd kcal-docker
cp .env.example .env
## 3. Generate and add an `APP_KEY` to the `.env` file.
docker-compose run app php artisan key:generate --show
This command will output a suitable key. Copy the key value and add it to the
`APP_KEY` value in the `.env` file. This also a good time to review make other
changes to the `.env` file (e.g. set the `APP_TIMEZONE` and `APP_URL` values as
desired).
## 4. Launch! :rocket:
docker-compose up -d
## 5. Set up application.
docker-compose exec app php artisan optimize
docker-compose exec app php artisan migrate
docker-compose exec app php artisan elastic:migrate
## 6. Create initial user.
docker-compose exec app php artisan user:add --admin

89
docker-compose.yml Normal file
View File

@ -0,0 +1,89 @@
version: '3'
services:
app:
image: kcalapp/kcal
container_name: kcal-app
restart: unless-stopped
tty: true
working_dir: /app
env_file: .env
volumes:
- 'app:/app'
- './etc/php/php.ini:/usr/local/etc/php/conf.d/local.ini'
networks:
- kcal
web:
image: nginx:alpine
container_name: kcal-web
restart: unless-stopped
tty: true
working_dir: /app
ports:
- '${APP_PORT:-80}:80'
- '${APP_PORT_SSL:-443}:443'
volumes:
- 'app:/app'
- './etc/nginx/conf.d/:/etc/nginx/conf.d/'
networks:
- kcal
depends_on:
- app
db:
image: mysql:8.0
container_name: kcal-db
restart: unless-stopped
tty: true
ports:
- '${DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_DATABASE: '${DB_DATABASE:-kcal}'
MYSQL_USER: '${DB_USERNAME:-kcal}'
MYSQL_PASSWORD: '${DB_PASSWORD:-kcal}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'db-data:/var/lib/mysql/'
- './etc/mysql/my.cnf:/etc/mysql/my.cnf'
networks:
- kcal
elasticsearch:
image: 'elasticsearch:7.12.0'
container_name: kcal-elasticsearch
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- 'elasticsearch-data:/usr/share/elasticsearch/data'
ports:
- '${ELASTIC_PORT:-9200}:9200'
networks:
- kcal
redis:
image: 'redis:alpine'
container_name: kcal-redis
ports:
- '${REDIS_PORT:-6379}:6379'
volumes:
- 'redis-data:/data'
networks:
- kcal
networks:
kcal:
driver: bridge
volumes:
app: {}
db-data:
driver: local
elasticsearch-data:
driver: local
redis-data:
driver: local

5
etc/mysql/my.cnf Normal file
View File

@ -0,0 +1,5 @@
[mysqld]
default-authentication-plugin = mysql_native_password
general_log = 1
general_log_file = /var/lib/mysql/general.log
secure-file-priv = NULL

30
etc/nginx/conf.d/app.conf Normal file
View File

@ -0,0 +1,30 @@
server {
listen 80;
root /app/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

2
etc/php/php.ini Normal file
View File

@ -0,0 +1,2 @@
upload_max_filesize=40M
post_max_size=40M