Skip to content

Commit

Permalink
setup repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Daiki Muroga authored and Daiki Muroga committed May 29, 2022
1 parent 8a157a6 commit 82a0e48
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# env file
.env

# tmp directory
tmp
17 changes: 17 additions & 0 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.18-alpine3.15

WORKDIR /app/go/base

RUN apk add --no-cache --update-cache \
alpine-sdk \
protoc

RUN go install github.com/cosmtrek/air@latest && \
go install github.com/golang/protobuf/protoc-gen-go@latest && \
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@latest && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && \
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest

COPY . .

#RUN go mod tidy
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.PHONY: docker-up
docker-up:
@docker-compose -f docker-compose.local.yml up -d

.PHONY: docker-down
docker-down:
@docker-compose -f docker-compose.local.yml down

.PHONY: docker-stop
docker-stop:
@docker-compose -f docker-compose.local.yml stop

.PHONY: docker-build
docker-build:
@docker-compose -f docker-compose.local.yml build

.PHONY: watch-log
watch-log:
@docker-compose -f docker-compose.local.yml logs -f blockchain
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# blockchain server
Provide a blockchain server.

## Version
- Docker:20.10.12
- golang:1.18

## Commands
### Run local
- `set .env file`
- `make docker-up`

### Build local
- `make docker-build`

### Watch log local
- `make watch-log`
47 changes: 47 additions & 0 deletions cmd/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Config file for [Air](https://github.com/cosmtrek/air) in TOML format

# 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 = "go build -o /tmp/main ./cmd/main.go"
# Binary file yields from `cmd`.
bin = "/tmp/main"
# Customize binary.
full_bin = "SERVER_ENV=local APP_USER=air /tmp/main"
# Watch these filename extensions.
include_ext = ["go", "tpl", "tmpl"]
# Ignore these filename extensions or directories.
exclude_dir = ["assets", "tmp", "vendor"]
# Watch these directories if you specified.
include_dir = []
# Exclude files.
exclude_file = []
# This log file places in your tmp_dir.
log = "air.log"
# It's not necessary to trigger build each time file changes if it's too frequent.
delay = 1000 # ms
# Stop running old binary when build errors occur.
stop_on_error = true
# Send Interrupt signal before killing process (windows does not support this feature)
send_interrupt = false
# Delay after sending Interrupt signal
kill_delay = 500 # ms

[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
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"fmt"
)

func main() {
fmt.Println("hello")
}
18 changes: 18 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"

services:
blockchain:
container_name: blockchain-server
build:
context: .
dockerfile: Dockerfile.local
command: "air -c /app/go/base/cmd/.air.toml"
env_file:
- .env
image: blockchain
volumes:
- .:/app/go/base:rw
tty: true
ports:
- ${REST_PORT}:${REST_PORT}
- ${GRPC_PORT}:${GRPC_PORT}

0 comments on commit 82a0e48

Please sign in to comment.