mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-08 13:29:53 +00:00
Merge pull request #46 from mritd/chore/docker
chore(docker): update dockerfile
This commit is contained in:
commit
16df31b1b8
41
.github/workflows/docker.yaml
vendored
Normal file
41
.github/workflows/docker.yaml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: Build Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get tag
|
||||||
|
uses: olegtarasov/get-tag@v2
|
||||||
|
id: tagName
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
tags: tobyxdd/hysteria:latest,tobyxdd/hysteria:${{ env.GIT_TAG_NAME }}
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
24
Dockerfile
24
Dockerfile
@ -1,40 +1,30 @@
|
|||||||
FROM golang:1.14.7-alpine3.12 AS builder
|
FROM golang:alpine AS builder
|
||||||
|
|
||||||
LABEL maintainer="mritd <mritd@linux.com>"
|
LABEL maintainer="mritd <mritd@linux.com>"
|
||||||
|
|
||||||
# The following parameters are used to set compilation information(such as compilation time,
|
|
||||||
# commit id, etc.). Use "docker build --build-arg VERSION=1.1.1 ..." to set these parameters.
|
|
||||||
# These parameters can be set automatically through CI Server.
|
|
||||||
ARG VERSION="Unknown"
|
|
||||||
ARG COMMIT="Unknown"
|
|
||||||
ARG TIMESTAMP="Unknown"
|
|
||||||
|
|
||||||
# GOPROXY is disabled by default, use:
|
# GOPROXY is disabled by default, use:
|
||||||
# docker build --build-arg GOPROXY="https://goproxy.io" ...
|
# docker build --build-arg GOPROXY="https://goproxy.io" ...
|
||||||
# to enable GOPROXY.
|
# to enable GOPROXY.
|
||||||
ARG GOPROXY=""
|
ARG GOPROXY=""
|
||||||
|
|
||||||
ENV VERSION ${VERSION}
|
|
||||||
ENV COMMIT ${COMMIT}
|
|
||||||
ENV TIMESTAMP ${TIMESTAMP}
|
|
||||||
ENV GOPROXY ${GOPROXY}
|
ENV GOPROXY ${GOPROXY}
|
||||||
|
|
||||||
# go mod is always enabled
|
|
||||||
ENV GO111MODULE on
|
|
||||||
|
|
||||||
COPY . /go/src/github.com/tobyxdd/hysteria
|
COPY . /go/src/github.com/tobyxdd/hysteria
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/tobyxdd/hysteria/cmd
|
WORKDIR /go/src/github.com/tobyxdd/hysteria/cmd
|
||||||
|
|
||||||
# TODO: Is it necessary to remove "-w -s" to add debugging information?
|
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
|
&& apk add git \
|
||||||
|
&& export VERSION=$(git describe --tags) \
|
||||||
|
&& export COMMIT=$(git rev-parse HEAD) \
|
||||||
|
&& export TIMESTAMP=$(date "+%F %T") \
|
||||||
&& go build -o /go/bin/hysteria -ldflags \
|
&& go build -o /go/bin/hysteria -ldflags \
|
||||||
"-w -s -X 'main.appVersion=${VERSION}' \
|
"-w -s -X 'main.appVersion=${VERSION}' \
|
||||||
-X 'main.appCommit=${COMMIT}' \
|
-X 'main.appCommit=${COMMIT}' \
|
||||||
-X 'main.appDate=${TIMESTAMP}'"
|
-X 'main.appDate=${TIMESTAMP}'"
|
||||||
|
|
||||||
# multi-stage builds to create the final image
|
# multi-stage builds to create the final image
|
||||||
FROM alpine:3.12 AS dist
|
FROM alpine AS dist
|
||||||
|
|
||||||
LABEL maintainer="mritd <mritd@linux.com>"
|
LABEL maintainer="mritd <mritd@linux.com>"
|
||||||
|
|
||||||
@ -50,4 +40,4 @@ RUN set -ex \
|
|||||||
|
|
||||||
COPY --from=builder /go/bin/hysteria /usr/local/bin/hysteria
|
COPY --from=builder /go/bin/hysteria /usr/local/bin/hysteria
|
||||||
|
|
||||||
ENTRYPOINT ["hysteria"]
|
ENTRYPOINT ["hysteria"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user