From d11888abd9d87bdd0d85a8f15a45d42bf5bedbc7 Mon Sep 17 00:00:00 2001 From: BlazeIsClone Date: Thu, 24 Oct 2024 17:34:43 +0530 Subject: [PATCH] config: dockerize application & add live reload --- .air.conf | 41 +++++++++++++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++---- docker-compose.yml | 12 ++++++++++-- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 .air.conf diff --git a/.air.conf b/.air.conf new file mode 100644 index 0000000..ee85e6e --- /dev/null +++ b/.air.conf @@ -0,0 +1,41 @@ +# Working directory +# . or absolute path, please note that the directories following must be under root. +root = "." +tmp_dir = "tmp" + +[build] +# Just plain old shell command. You could use `make` as well. +cmd = "make build" +# Binary file yields from `cmd`. +bin = "build" +# Customize binary. +full_bin = "./build" +# Watch these filename extensions. +include_ext = ["go", "tpl", "tmpl", "html"] +# Ignore these filename extensions or directories. +exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"] +# Watch these directories if you specified. +include_dir = [] +# Exclude files. +exclude_file = [] +# It's not necessary to trigger build each time file changes if it's too frequent. +delay = 1000 # ms +# Stop to run old binary when build errors occur. +stop_on_error = true +# This log file places in your tmp_dir. +log = "air_errors.log" + +[log] +# Show log time +time = false + +[color] +# Customize each part's color. If no color found, use the raw app log. +main = "magenta" +watcher = "cyan" +build = "yellow" +runner = "green" + +[misc] +# Delete tmp directory on exit +clean_on_exit = true \ No newline at end of file diff --git a/README.md b/README.md index d17bd05..b21ad5b 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,34 @@ [![Go](https://img.shields.io/badge/go-00ADD8.svg?style=for-the-badge&logo=go&logoColor=white)](https://go.dev/) -Order management microservice. +Mission Control microservice. ## Development -To get started, clone this repository and follow theese steps. +To get started, clone this repository and follow these steps to run the Go application in your local environment. -Run Docker Containers: +Start all of the Docker containers in the background, you may start in "detached" mode: ```bash docker-compose up -d ``` -Running Database Migrations (use arg action): +The application is executing within a Docker container and is isolated from your local computer. To run various commands against your application use: + +```bash +docker-compose exec app {CMD} +``` + +## Database Migrations + +Run all of your outstanding migrations: ```bash make migrate action=up ``` + +Roll back the latest migration operation, you may use the rollback Artisan command. This command rolls back the last "batch" of migrations, which may include multiple migration files: + +```bash +make migrate action=down +``` diff --git a/docker-compose.yml b/docker-compose.yml index 6fb0552..8fffdf8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,14 @@ -version: '3' - services: + app: + image: cosmtrek/air + working_dir: /app + ports: + - 80:3000 + env_file: ".env" + volumes: + - ./:/app + depends_on: + - mysql mysql: image: mariadb environment: