Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
YUN BAI committed Jun 14, 2024
1 parent e09b31a commit 847c59d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,28 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: 12345dotblue/dotblue
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=branch
- name: Build and push streampark
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
file: manifest/docker/Dockerfile
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.GITHUB_REPOSITORY_NAME_PART }}:${{ github.ref }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}






29 changes: 20 additions & 9 deletions manifest/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
FROM loads/alpine:3.8
FROM FROM golang:alpine as build

###############################################################################
# INSTALLATION
# build
###############################################################################

ENV WORKDIR /app
ADD resource $WORKDIR/
ADD ./temp/linux_amd64/main $WORKDIR/main
RUN chmod +x $WORKDIR/main
ENV WORKDIR /release
ADD . .

RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -ldflags="-s -w" -o dotblue main.go

RUN chmod +x $WORKDIR/dotblue

###############################################################################
# START
# run
###############################################################################
WORKDIR $WORKDIR
CMD ./main
FROM scratch as prod

# 在build阶段复制时区到
#COPY --from=build /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# 在build阶段复制可执行的go二进制文件app
COPY --from=build /release/dotblue /
# 在build阶段复制配置文件
COPY --from=build /release/manifest/config /config

# 启动服务
CMD ["/dotblue", "-c", "/config/config.yaml"]

0 comments on commit 847c59d

Please sign in to comment.