Skip to content

Commit

Permalink
feat: add test file
Browse files Browse the repository at this point in the history
Signed-off-by: Xinwei Xiong(cubxxw-openim) <[email protected]>
  • Loading branch information
cubxxw committed Jul 17, 2023
1 parent add4b00 commit 1b86e04
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 87 deletions.
148 changes: 74 additions & 74 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,77 +140,77 @@ checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
algorithm: sha256

dockers:
- use: buildx
ids:
- syncer
goos: linux
goarch: amd64
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64
dockerfile: docker/syncer/Dockerfile.release
build_flag_templates:
- --pull
- --platform=linux/amd64
- --label=io.sealos.image.created={{.Date}}
- --label=io.sealos.image.title=syncer
- --label=io.sealos.image.revision={{.ShortCommit}}
- --label=io.sealos.image.version={{.Tag }}
- --label=io.sealos.image.auth={{ .Env.USERNAME }}
- use: buildx
ids:
- syncer
goos: linux
goarch: arm64
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-arm64
dockerfile: docker/syncer/Dockerfile.release
build_flag_templates:
- --pull
- --platform=linux/arm64
- --label=io.sealos.image.created={{.Date}}
- --label=io.sealos.image.title=lvscare
- --label=io.sealos.image.revision={{.ShortCommit}}
- --label=io.sealos.image.version={{.Tag }}
- --label=io.sealos.image.auth={{ .Env.USERNAME }}
- use: buildx
ids:
- sealos
goos: linux
goarch: amd64
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-amd64
dockerfile: docker/sealos/Dockerfile.release
build_flag_templates:
- --pull
- --platform=linux/amd64
- --label=io.sealos.image.created={{.Date}}
- --label=io.sealos.image.title=sealos
- --label=io.sealos.image.revision={{.ShortCommit}}
- --label=io.sealos.image.version={{.Tag }}
- --label=io.sealos.image.auth={{ .Env.USERNAME }}
- use: buildx
ids:
- sealos
goos: linux
goarch: arm64
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-arm64
dockerfile: docker/sealos/Dockerfile.release
build_flag_templates:
- --pull
- --platform=linux/arm64
- --label=io.sealos.image.created={{.Date}}
- --label=io.sealos.image.title=sealos
- --label=io.sealos.image.revision={{.ShortCommit}}
- --label=io.sealos.image.version={{.Tag }}
- --label=io.sealos.image.auth={{ .Env.USERNAME }}
docker_manifests:
- name_template: ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}-amd64
- ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}-arm64
- name_template: ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}
image_templates:
- ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-amd64
- ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-arm64
# dockers:
# - use: buildx
# ids:
# - syncer
# goos: linux
# goarch: amd64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-amd64
# dockerfile: docker/syncer/Dockerfile.release
# build_flag_templates:
# - --pull
# - --platform=linux/amd64
# - --label=io.sealos.image.created={{.Date}}
# - --label=io.sealos.image.title=syncer
# - --label=io.sealos.image.revision={{.ShortCommit}}
# - --label=io.sealos.image.version={{.Tag }}
# - --label=io.sealos.image.auth={{ .Env.USERNAME }}
# - use: buildx
# ids:
# - syncer
# goos: linux
# goarch: arm64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/syncer:{{ .Tag }}-arm64
# dockerfile: docker/syncer/Dockerfile.release
# build_flag_templates:
# - --pull
# - --platform=linux/arm64
# - --label=io.sealos.image.created={{.Date}}
# - --label=io.sealos.image.title=lvscare
# - --label=io.sealos.image.revision={{.ShortCommit}}
# - --label=io.sealos.image.version={{.Tag }}
# - --label=io.sealos.image.auth={{ .Env.USERNAME }}
# - use: buildx
# ids:
# - sealos
# goos: linux
# goarch: amd64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-amd64
# dockerfile: docker/sealos/Dockerfile.release
# build_flag_templates:
# - --pull
# - --platform=linux/amd64
# - --label=io.sealos.image.created={{.Date}}
# - --label=io.sealos.image.title=sealos
# - --label=io.sealos.image.revision={{.ShortCommit}}
# - --label=io.sealos.image.version={{.Tag }}
# - --label=io.sealos.image.auth={{ .Env.USERNAME }}
# - use: buildx
# ids:
# - sealos
# goos: linux
# goarch: arm64
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-arm64
# dockerfile: docker/sealos/Dockerfile.release
# build_flag_templates:
# - --pull
# - --platform=linux/arm64
# - --label=io.sealos.image.created={{.Date}}
# - --label=io.sealos.image.title=sealos
# - --label=io.sealos.image.revision={{.ShortCommit}}
# - --label=io.sealos.image.version={{.Tag }}
# - --label=io.sealos.image.auth={{ .Env.USERNAME }}
# docker_manifests:
# - name_template: ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/lvscare:{{ .Tag }}-arm64
# - name_template: ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}
# image_templates:
# - ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-amd64
# - ghcr.io/{{ .Env.USERNAME }}/sealos:{{ .Tag }}-arm64
23 changes: 16 additions & 7 deletions deploy/Dockerfile.exporter
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
FROM golang:1.20-alpine
# docker build -t exporter:1.0 -f ./Dockerfile.exporter .
# 构建阶段1:构建二进制文件
FROM golang:1.20 as builder

# 设置工作目录
WORKDIR /app

COPY . .
# 复制项目文件到容器中
COPY cmd/exporter/main.go go.mod go.sum /app/

RUN apk update && apk add make
# 构建二进制文件
RUN CGO_ENABLED=0 GOOS=linux go build -o exporter main.go

RUN make exporter

# 构建阶段2:生成最终镜像
FROM alpine:latest

COPY --from=0 /app/_output/bin/platforms/linux/amd64/exporter /app/exporter
# 设置工作目录
WORKDIR /app

# 从构建阶段1中复制二进制文件到容器中
COPY --from=builder /app/exporter /app/exporter

ENTRYPOINT ["/app/exporter"]
# 运行二进制文件
CMD ["/app/exporter --help"]
22 changes: 16 additions & 6 deletions deploy/Dockerfile.syncer
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
FROM golang:1.20-alpine
# docker build -t syncer:1.0 -f ./Dockerfile.syncer .
WORKDIR /app
# 构建阶段1:构建二进制文件
FROM golang:1.20 as builder

COPY . .
# 设置工作目录
WORKDIR /app

RUN apk update && apk add make
# 复制项目文件到容器中
COPY cmd/exporter/main.go go.mod go.sum /app/

RUN make syncer
# 构建二进制文件
RUN CGO_ENABLED=0 GOOS=linux go build -o exporter main.go

# 构建阶段2:生成最终镜像
FROM alpine:latest

COPY --from=0 /app/_output/bin/platforms/linux/amd64/syncer /app/syncer
# 设置工作目录
WORKDIR /app

# 从构建阶段1中复制二进制文件到容器中
COPY --from=builder /app/syncer /app/syncer

ENTRYPOINT ["/app/syncer"]
# 运行二进制文件
CMD ["/app/syncer --help"]

0 comments on commit 1b86e04

Please sign in to comment.