mirror of
https://github.com/supanadit/short-url.git
synced 2024-11-21 09:46:22 +00:00
feat: add docker support
This commit is contained in:
parent
f5318a6942
commit
a0f995d00a
15
.dockerignore
Normal file
15
.dockerignore
Normal file
@ -0,0 +1,15 @@
|
||||
.github/
|
||||
.idea/
|
||||
.vscode/
|
||||
tests
|
||||
docker-compose.yml
|
||||
.dockerignore
|
||||
.editorconfig
|
||||
.gitattributes
|
||||
.gitignore
|
||||
.styleci.yml
|
||||
Dockerfile
|
||||
phpunit.xml
|
||||
README.md
|
||||
|
||||
mysql
|
39
.env.docker
Executable file
39
.env.docker
Executable file
@ -0,0 +1,39 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_CONNECTION=sync
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -11,4 +11,7 @@ Homestead.yaml
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
.idea
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
mysql/
|
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@ -0,0 +1,53 @@
|
||||
FROM php:7.4-apache
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
# 1. development packages
|
||||
RUN apt-get install -y \
|
||||
git \
|
||||
zip \
|
||||
curl \
|
||||
sudo \
|
||||
unzip \
|
||||
libicu-dev \
|
||||
libzip-dev \
|
||||
libbz2-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libmcrypt-dev \
|
||||
libreadline-dev \
|
||||
libfreetype6-dev \
|
||||
g++
|
||||
|
||||
# Set Apache Root
|
||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
|
||||
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||
|
||||
# Enable Some Apache Mod
|
||||
RUN a2enmod rewrite headers
|
||||
|
||||
RUN docker-php-ext-install \
|
||||
bz2 \
|
||||
intl \
|
||||
iconv \
|
||||
bcmath \
|
||||
opcache \
|
||||
calendar \
|
||||
pdo_mysql \
|
||||
zip
|
||||
|
||||
# Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
# Copy Source Code
|
||||
COPY .env.docker /var/www/html/.env
|
||||
COPY . /var/www/html
|
||||
|
||||
# Change Working Directory
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Composer install and generate key
|
||||
RUN composer install && php artisan key:generate
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/html
|
35
README.md
35
README.md
@ -51,6 +51,41 @@ This is url shortener application is similar to [bit.ly](http://bit.ly)
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
## Docker Way
|
||||
|
||||
This app can run inside docker with official support
|
||||
|
||||
### Via Docker Compose
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Run Migration
|
||||
|
||||
```bash
|
||||
docker-compose exec todo-app php artisan migrate
|
||||
```
|
||||
|
||||
### Run Seeder
|
||||
|
||||
```bash
|
||||
docker-compose exec todo-app php artisan db:seed
|
||||
```
|
||||
|
||||
### Build Docker By Yourself
|
||||
|
||||
```bash
|
||||
docker build . -t supanadit/short-url:1.0.2
|
||||
```
|
||||
|
||||
### Troubleshooting MySQL Won't Run In Docker
|
||||
|
||||
Run this script `sudo chown -R 1001:1001 mysql`
|
||||
|
||||
Because we used Bitnami distribution version of MySQL, so we need to change the permission of mysql folder, since it
|
||||
also described in docker page of bitnami
|
||||
|
||||
## Note
|
||||
|
||||
If you want to use forgot password feature, you must provide your email and password at `.env`
|
||||
|
25
docker-compose.yml
Normal file
25
docker-compose.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: "2"
|
||||
services:
|
||||
mysql:
|
||||
image: "bitnami/mysql:8.0"
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- "./mysql:/bitnami/mysql/data"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=secret
|
||||
- MYSQL_DATABASE=short
|
||||
|
||||
todo-app:
|
||||
image: "supanadit/short-url:1.0.2"
|
||||
ports:
|
||||
- "80:80"
|
||||
environment:
|
||||
- DB_CONNECTION=mysql
|
||||
- DB_HOST=mysql
|
||||
- DB_PORT=3306
|
||||
- DB_DATABASE=short
|
||||
- DB_USERNAME=root
|
||||
- DB_PASSWORD=secret
|
||||
depends_on:
|
||||
- mysql
|
Loading…
Reference in New Issue
Block a user