doc: add how to run and dockerfile

This commit is contained in:
xkm
2026-04-01 21:31:26 +08:00
parent 0e695c3282
commit 995e196caa
2 changed files with 49 additions and 2 deletions

21
Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
FROM docker.io/golang:1.26.1-trixie AS builder
WORKDIR /build
COPY go.mod go.sum .
RUN GOPROXY='https://goproxy.cn,direct' go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o /app ./cmd/api
FROM scratch
WORKDIR /
COPY --from=builder /app /app
COPY db/ /db
ENTRYPOINT ["/app"]

View File

@@ -6,6 +6,32 @@ The backend of a bigdata market.
## Usage
env:
### env
- DATABASE_URL example:"postgres://datamarket:datamarket@localhost:5432/datamarket?sslmode=disable"
- SERVER_ADDR default :8080
### run
#### docker
use `docker.io/starryskymeow/datamarket-backend:latest`
#### go
```shell
go run cmd/api/main.go
```
### db
```shell
# run a test db, you can use docker instead of podman
podman run -d \
--name datamarket-db-dev \
-p 127.0.0.1:5432:5432 \
-e POSTGRES_USER=datamarket \
-e POSTGRES_PASSWORD=datamarket \
-e POSTGRES_DB=datamarket \
-v datamarket-db-dev:/var/lib/postgresql/data \
docker.io/library/postgres:17
```