From 873e8dfd2ba99cbe2f2f2a7b96ba564ec3ed48d5 Mon Sep 17 00:00:00 2001 From: xuthus5 Date: Sun, 22 Oct 2023 01:39:43 +0800 Subject: [PATCH] feat: db file to data directory --- .gitignore | 3 ++- Dockerfile | 10 +++++----- config_dev.yaml | 4 ++-- config_prod.yaml | 4 ++-- data/.gitkeep | 0 docker-compose.yaml | 6 +++--- 6 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 data/.gitkeep diff --git a/.gitignore b/.gitignore index 9161edc..166ba7d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ go.sum pastebin pastebin.exe pastebin.exe~ -pastebin.db \ No newline at end of file +pastebin.db +data/pastebin.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7ed94cd..7b39b98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,10 @@ COPY ./webui . RUN npm install && npm run build FROM images.local/golang:latest +WORKDIR /app +COPY . /app +COPY --from=0 dist /app/webui/dist +RUN go mod tidy && go build . -COPY . . -COPY --from=0 dist ./webui/dist -RUN buf generate && go mod tidy && go build . - -EXPOSE 38080 +EXPOSE 38081 ENTRYPOINT [ "./pastebin", "api" ] diff --git a/config_dev.yaml b/config_dev.yaml index b9fd63e..1676574 100644 --- a/config_dev.yaml +++ b/config_dev.yaml @@ -1,6 +1,6 @@ server-name: pastebin -server-listen: 127.0.0.1:38080 +server-listen: 127.0.0.1:38082 environment: dev db: - dbname: pastebin.db + dbname: data/pastebin.db debug: true diff --git a/config_prod.yaml b/config_prod.yaml index e6a4940..093e7d6 100644 --- a/config_prod.yaml +++ b/config_prod.yaml @@ -1,6 +1,6 @@ server-name: pastebin -server-listen: 0.0.0.0:38080 +server-listen: 0.0.0.0:38082 environment: prod db: - dbname: pastebin.db + dbname: data/pastebin.db debug: true diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yaml b/docker-compose.yaml index ce974f9..172029d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,10 +2,10 @@ version: "3" services: server: - image: xuthus5/pastebin:latest + image: images.local/pastebin:latest container_name: pastebin restart: always volumes: - - /data/containers/pastebin:/app/data + - /data/containers/pastebin/pastebin.db:/app/pastebin.db ports: - - "30001:38080" + - "30002:38082"