diff --git a/Dockerfile b/Dockerfile index 892013c..789365d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ FROM golang:1.20 AS api # Set working directory. WORKDIR /compiler +# Env GOPROY +ENV GOPROXY="https://proxy.golang.com.cn,direct" + # Copy dependency locks so we can cache. COPY go.mod go.sum ./ diff --git a/docker-compose.yml b/docker-compose.yml index 99d70ea..b6a5f81 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,6 +27,8 @@ services: - ./scripts/billMigrations.sql:/docker-entrypoint-initdb.d/1.sql expose: - 3306 + ports: + - 3306:3306 environment: - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=true networks: diff --git a/internal/infrastructure/mariadb.go b/internal/infrastructure/mariadb.go index 03b71ec..ed3c3b7 100644 --- a/internal/infrastructure/mariadb.go +++ b/internal/infrastructure/mariadb.go @@ -8,7 +8,7 @@ import ( // This function is used to connect to MariaDB. func ConnectToMariaDB() (*sql.DB, error) { // Connect to MariaDB. - db, err := sql.Open("mysql", "root:@tcp(mariadb:3306)/fiber_dmca") + db, err := sql.Open("mysql", "root:@tcp(mariadb:3306)/bill") if err != nil { return nil, err } diff --git a/scripts/billMigrations.sql b/scripts/billMigrations.sql index 94f63d6..49fbb5e 100644 --- a/scripts/billMigrations.sql +++ b/scripts/billMigrations.sql @@ -4,16 +4,14 @@ USE bill; create table Bills ( - id int auto_increment - primary key, + id int auto_increment primary key, type varchar(15) not null, date varchar(15) not null, money varchar(900) null, cls varchar(900) null, label varchar(900) null, options varchar(900) null -) - charset = utf8mb4; +); INSERT INTO bill.Bills (id, type, date, money, cls, label, options) VALUES (3341, 'INCOME', '2022-09-01', '8.5', '交通', '打的', ''); @@ -74,6 +72,4 @@ VALUES (3368, 'INCOME', '2022-07-07', '14.4', '餐饮', '午餐', ''); INSERT INTO bill.Bills (id, type, date, money, cls, label, options) VALUES (3369, 'INCOME', '2022-07-07', '1.6', '交通', '公交', ''); INSERT INTO bill.Bills (id, type, date, money, cls, label, options) -VALUES (3370, 'INCOME', '2022-07-07', '9.0', '餐饮', '晚餐', ''); -INSERT INTO bill.Bills (id, type, date, money, cls, label, options) -VALUES (3371, 'INCOME', '2022-07-07', '5.5', '餐饮', '晚餐', ''); \ No newline at end of file +VALUES (3370, 'INCOME', '2022-07-07', '9.0', '餐饮', '晚餐', ''); \ No newline at end of file