fix: dockerfile & mariadb database
This commit is contained in:
parent
7862701a26
commit
1a1fc59b10
|
@ -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 ./
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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', '餐饮', '晚餐', '');
|
||||
VALUES (3370, 'INCOME', '2022-07-07', '9.0', '餐饮', '晚餐', '');
|
Loading…
Reference in New Issue
Block a user