Skip to content

Commit

Permalink
config: dockerize application & add live reload
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazeIsClone committed Oct 24, 2024
1 parent 251ea47 commit d11888a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 6 deletions.
41 changes: 41 additions & 0 deletions .air.conf
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
12 changes: 10 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit d11888a

Please sign in to comment.