Skip to content

Commit

Permalink
Merge pull request #7 from traPtitech/update-deprecates
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-20 authored Dec 18, 2024
2 parents e7def80 + 9158c0b commit 4b955a8
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 129 deletions.
23 changes: 12 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
FROM golang:1.22.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/*
FROM golang:1.23.0-alpine AS build

WORKDIR /app
RUN go install github.com/air-verse/air@latest

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

CMD ["air"]
COPY . .
RUN go build -o app

FROM alpine:3 AS runtime

WORKDIR /app
COPY --from=build /app/app .

RUN mkdir -p /app/data

CMD ["./app"]
46 changes: 9 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# booQ

[![GitHub release](https://img.shields.io/github/release/traPtitech/booQ.svg)](https://GitHub.com/traPtitech/booQ/releases/)
![CI](https://github.com/traPtitech/booQ/workflows/CI/badge.svg)
![master](https://github.com/traPtitech/booQ/workflows/master/badge.svg)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=traPtitech/booQ)](https://dependabot.com)
[![GitHub release](https://img.shields.io/github/release/traPtitech/booQ-v3.svg)](https://GitHub.com/traPtitech/booQ-v3/releases/)
![CI](https://github.com/traPtitech/booQ-v3/workflows/CI/badge.svg)
![master](https://github.com/traPtitech/booQ-v3/workflows/master/badge.svg)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=traPtitech/booQ-v3)](https://dependabot.com)

management tool for equipment and book rental

Expand All @@ -14,55 +14,27 @@ management tool for equipment and book rental
#### First Up (or entirely rebuild)

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

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`

You can also execute build shell script

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

And start development

```
$ sh scripts/up.sh
```
`docker compose exec db bash` and `mysql -uroot -ppassword -Dbooq`

#### 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
$ docker compose -f docker/test/docker-compose.yml up --abort-on-container-exit
```

#### Rebuild

`docker-compose up --no-deps --build`
`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 )
2. Create your feature branch (git checkout -b issue-{{number}}) e.g. `issue-1`
3. Commit your changes (git commit -m 'Add some feature')
4. Push to the branch (git push origin issue-{{number}})
5. Create new Pull Request
`docker compose down -v`

48 changes: 0 additions & 48 deletions compose-dev.yml

This file was deleted.

54 changes: 29 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
version: "3"
services:
db:
image: mariadb:10.11.7
image: mariadb:11.5.2
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: booq-v3
MYSQL_USERNAME: root
MYSQL_PASSWORD: password
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
volumes:
- booq-db:/var/lib/mysql
- ./docker/init.sql:/docker-entrypoint-initdb.d/init.sql
expose:
- "3306"
- '3306'
ports:
- "3306:3306"
- '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

test: ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized']
start_period: 10s
interval: 10s
timeout: 5s
retries: 3
booq-server:
build: .
environment:
Expand All @@ -28,27 +28,31 @@ services:
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_DATABASE: booq-v3
volumes:
- "./:/app"
tty: true
UPLOAD_DIR: /app/data
ports:
- "8080:3001"
- '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"

develop:
watch:
- path: ./Dockerfile
action: rebuild
- path: ./go.mod
action: rebuild
- path: ./main.go
action: rebuild
- path: ./model
action: rebuild
- path: ./router
action: rebuild
- path: ./storage
action: rebuild
adminer:
image: adminer
restart: always
ports:
- 8000:8080

volumes:
booq-db:
5 changes: 5 additions & 0 deletions docker/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SET
character_set_server = 'utf8mb4';

SET
collation_server = 'utf8mb4_general_ci';
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/traPtitech/booQ-v3

go 1.22
go 1.23

require (
github.com/go-ozzo/ozzo-validation/v4 v4.3.0
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
func main() {
err := model.EstablishConnection()
if err != nil {
panic(err)
log.Fatal(err)
}

err = model.Migrate()
if err != nil {
panic(err)
log.Fatal(err)
}

setStorage()
Expand Down Expand Up @@ -51,7 +51,7 @@ func setStorage() {
os.Getenv("OS_AUTH_URL"),
)
if err != nil {
panic(err)
log.Fatal(err)
}
} else {
// ローカルストレージ
Expand All @@ -61,7 +61,7 @@ func setStorage() {
}
err := storage.SetLocalStorage(dir)
if err != nil {
panic(err)
log.Fatal(err)
}
}
}
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker-compose build
docker compose build
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker-compose -f docker/test/docker-compose.yml up --abort-on-container-exit
docker compose -f docker/test/docker-compose.yml up --abort-on-container-exit
2 changes: 1 addition & 1 deletion scripts/up.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docker-compose up
docker compose up

0 comments on commit 4b955a8

Please sign in to comment.