Skip to content

Commit

Permalink
Revert "Revert v1.5.0"
Browse files Browse the repository at this point in the history
This reverts commit 996b882.
  • Loading branch information
cp-20 committed Nov 8, 2023
1 parent 9ff6ef9 commit 1fc0538
Show file tree
Hide file tree
Showing 31 changed files with 1,002 additions and 352 deletions.
63 changes: 63 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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/runner-build -buildvcs=false ."
# Binary file yields from `cmd`.
bin = "tmp/runner-build"
# Customize binary, can setup environment variables when run your app.
full_bin = "APP_ENV=dev APP_USER=air ./tmp/runner-build"
# Watch these filename extensions.
include_ext = ["go"]
# Ignore these filename extensions or directories.
exclude_dir = []
# Watch these directories if you specified.
include_dir = []
# Watch these files.
include_file = []
# Exclude files.
exclude_file = []
# Exclude specific regular expressions.
exclude_regex = ["_test\\.go"]
# Exclude unchanged files.
exclude_unchanged = true
# Follow symlink for directories
follow_symlink = true
# 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 = 0 # 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
# Rerun binary or not
rerun = false
# Delay after each executions
rerun_delay = 500
# Add additional arguments when running binary (bin/full_bin). Will run './tmp/main hello world'.
args_bin = []

[log]
# Show log time
time = false
# Only show main log (silences watcher, build, runner)
main_only = 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
77 changes: 15 additions & 62 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,35 @@ on:
pull_request:

jobs:
mod:
name: Server Modules
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
- run: go mod download
build:
name: Server Build
runs-on: ubuntu-latest
needs: [mod]
env:
GOCACHE: "/tmp/go/cache"
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/checkout@v2
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- uses: actions/cache@v2
with:
path: /tmp/go/cache
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-build-${{ github.ref }}-
${{ runner.os }}-go-build-
go-version-file: ./go.mod
- name: mod
run: go mod download
- name: build
run: go build
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: booQ
path: booQ
lint:
name: Server Lint
runs-on: ubuntu-latest
needs: [mod]
needs: [build]
steps:
- uses: actions/setup-go@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.15
go-version-file: ./go.mod
- name: Install reviewdog
run: curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Install golangci-lint
run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- name: golangci-lint
run: golangci-lint run --out-format=line-number | reviewdog -f=golangci-lint -name=golangci-lint -reporter=github-check
env:
Expand All @@ -78,7 +45,6 @@ jobs:
runs-on: ubuntu-latest
needs: [build]
env:
GOCACHE: "/tmp/go/cache"
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: booq_test
Expand All @@ -92,23 +58,10 @@ jobs:
ports:
- 3306:3306
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- uses: actions/cache@v2
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
path: /tmp/go/cache
key: ${{ runner.os }}-go-build-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-build-${{ github.ref }}-
${{ runner.os }}-go-build-
go-version-file: ./go.mod
- name: Setup DB
run: go run .github/workflows/init.go
- name: Run model tests
Expand All @@ -119,9 +72,9 @@ jobs:
name: OpenApi Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Spectral checks
uses: stoplightio/spectral-action@v0.8.2
uses: stoplightio/spectral-action@v0.8.10
with:
file_glob: docs/swagger.yml
repo_token: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
name: Build Docker Image (master)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: traptitech
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ jobs:
steps:
- name: Set IMAGE_TAG env
run: echo "IMAGE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: traptitech
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
push: true
file: docker/production/Dockerfile
tags: |
ghcr.io/traptitech/${{ env.IMAGE_NAME }}:latest
ghcr.io/traptitech/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
15 changes: 7 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM golang:1.15.0-alpine AS build
FROM golang:1.20.0-alpine AS build
ENV CGO_ENABLED=0
ENV DOCKERIZE_VERSION v0.6.1
RUN apk add --update --no-cache git && \
apk --update add tzdata && \
cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
apk del tzdata && \
rm -rf /var/cache/apk/*
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \
rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz

WORKDIR /go/src/github.com/traPtitech/booQ
RUN go get github.com/pilu/fresh
COPY ./go.* ./
WORKDIR /app
RUN go install github.com/cosmtrek/air@latest

COPY go.mod go.sum ./
RUN go mod download
COPY . .

CMD ["air"]
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,56 @@
management tool for equipment and book rental

## Development environment

### Setup with docker and docker-compose

#### First Up (or entirely rebuild)

```
$ docker-compose up --build
$ docker compose -f .\compose-dev.yml up --build
```

Now you can access to `http://localhost:3000` for booQ
Now you can access to `http://localhost:8080` for booQ

And you can access booQ MariaDB by executing commands
`docker-compose exec db bash` and `mysql -uroot -ppassword -Dbooq`
`docker-compose exec db bash` and `mysql -uroot -ppassword -Dbooq`

You can also execute build shell script

```
$ sh scripts/build.sh
```

And start development

```
$ sh scripts/up.sh
```
```

#### test

You can test this project

```
$ docker-compose -f docker/test/docker-compose.yml up --abort-on-container-exit
```

Or you can also execute test shell script

```
$ sh scripts/test.sh
```

#### Rebuild

`docker-compose up --no-deps --build`

#### Destroy Containers and Volumes

`docker-compose down -v`

## Contribution

The task list is in [issue](https://github.com/traPtitech/booQ/issues)

1. Fork it ( https://github.com/traPtitech/booQ )
Expand Down
47 changes: 47 additions & 0 deletions compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3"
services:
db:
image: mariadb:10.6.4
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: booq
MYSQL_USERNAME: root
MYSQL_PASSWORD: password
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
expose:
- '3306'
ports:
- '3306:3306'
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u$$MYSQL_USERNAME -p$$MYSQL_ROOT_PASSWORD
interval: 6s
timeout: 60s
retries: 20
start_period: 5s

booq-server:
build: .
environment:
BOOQ_ENV: development
MYSQL_HOST: db
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: booq
DEBUG_USER_NAME: ryoha
volumes:
- './:/app'
tty: true
ports:
- '8080:3001'
depends_on:
db:
condition: service_healthy

swagger:
image: swaggerapi/swagger-ui
volumes:
- ./docs/swagger.yml:/usr/share/nginx/html/sample.yaml
environment:
API_URL: sample.yaml
ports:
- "4000:8080"
Loading

0 comments on commit 1fc0538

Please sign in to comment.