Skip to content

Commit b659f2a

Browse files
committed
[Refactor] ♻️ Docker Build Template #3
1 parent 8386b53 commit b659f2a

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM golang:1.21.4-alpine AS builder
1+
FROM golang:1.23.6-alpine AS builder
22
LABEL stage=gobuilder \
3-
mainatiner=https://github.com/mayooot/gpu-docker-api
3+
mainatiner=https://github.com/XShengTech/gpu-docker-api
44

5-
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
6-
RUN apk add gcc g++ make libffi-dev openssl-dev libtool
5+
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
6+
RUN apk add gcc g++ make libffi-dev openssl-dev libtool git
77

88
ENV CGO_ENABLED 0
9-
ENV GOPROXY https://goproxy.cn,direct
9+
# ENV GOPROXY https://goproxy.cn,direct
1010

1111
WORKDIR /build
1212

@@ -15,14 +15,19 @@ COPY go.sum .
1515
RUN go mod download
1616

1717
COPY . .
18-
RUN make linux_no_ldflags
18+
RUN BRANCH=$(git rev-parse --abbrev-ref HEAD) && \
19+
VERSION=$(git describe --tags | cut -d'-' -f1) && \
20+
COMMIT=$(git rev-parse --short HEAD) && \
21+
GO_VERSION=$(go env GOVERSION) && \
22+
BUILD_TIME=$(date +%FT%T%z) && \
23+
go build -ldflags="-s -w -X main.BRANCH=${BRANCH} -X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.GoVersion=${GO_VERSION} -X main.BuildTime=${BUILD_TIME}" -trimpath -o gpu-docker-api cmd/gpu-docker-api/main.go
1924

20-
FROM nvidia/cuda:10.0-base
25+
FROM ubuntu:22.04
2126

2227
VOLUME /data
2328
WORKDIR /data
2429

25-
COPY --from=builder /build/bin/gpu-docker-api-linux-amd64 /data/gpu-docker-api
30+
COPY --from=builder /build/gpu-docker-api /data/gpu-docker-api
2631

2732
EXPOSE 2378
2833

docker-compose.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ services:
3535

3636
gpu-docker-api:
3737
hostname: gpu-docker-api
38-
image: mayooot/gpu-docker-api:v0.0.3
38+
image: xshengtech/gpu-docker-api:latest
3939
container_name: gpu-docker-api
4040
restart: unless-stopped
4141
network_mode: host
42+
runtime: nvidia
43+
environment:
44+
- APIKEY=CHANGETHIS
4245
deploy:
4346
resources:
4447
reservations:

0 commit comments

Comments
 (0)