Skip to content

Commit 9bcd9ea

Browse files
committed
ci: docker build
1 parent a381fee commit 9bcd9ea

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

.dockerignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tmp
2+
.github
3+
.vscode
4+
*.md
5+
config.json

.github/workflows/docker-image.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Set up QEMU
12+
uses: docker/setup-qemu-action@v2
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v2
15+
- name: Login to Docker Hub
16+
uses: docker/login-action@v2
17+
with:
18+
username: ${{ secrets.DOCKERHUB_USERNAME }}
19+
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
- name: Build and push
21+
uses: docker/build-push-action@v4
22+
with:
23+
push: true
24+
platforms: linux/amd64,linux/arm64
25+
tags: 0xjerry/mindav:latest

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM golang:1.20 AS builder
2+
COPY go.mod /src/go.mod
3+
COPY go.sum /src/go.sum
4+
5+
ENV GOPROXY=https://mirrors.aliyun.com/goproxy/
6+
# ENV CGO_ENABLED=0
7+
WORKDIR /src/
8+
9+
RUN go mod download
10+
11+
COPY . /src/
12+
RUN go build -o /src/mindav /src/main.go
13+
14+
FROM debian:stable-slim
15+
# Copy our static executable.
16+
COPY --from=builder /src/mindav /mindav/mindav
17+
18+
WORKDIR /mindav/
19+
20+
# Run the server binary.
21+
22+
ENTRYPOINT ["/mindav/mindav"]
23+
24+
EXPOSE 8080

docker-compose.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3"
2+
services:
3+
4+
mindav:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ./config.json:/mindav/config.json
10+
ports:
11+
- "9000:8080"

0 commit comments

Comments
 (0)