Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b90cdfc2a1 | ||
|
|
e8f7a1b0bb | ||
|
|
7d78f5161e | ||
|
|
46e5a624be | ||
|
|
5e4c3bb21a | ||
|
|
75d7307134 | ||
|
|
ece420b56b | ||
|
|
c87861b4d6 | ||
|
|
69ea717d13 | ||
|
|
ff87416602 | ||
|
|
231518cb79 | ||
|
|
0950175e43 | ||
|
|
d7c0c2ed79 | ||
|
|
e8d7ae0889 |
56
.github/workflows/docker-hub-build-push-on-push.yml
vendored
Normal file
56
.github/workflows/docker-hub-build-push-on-push.yml
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
name: Build docker image and push to docker hub on release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
||||
|
||||
jobs:
|
||||
build_and_push:
|
||||
name: Build and push Docker image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract tag string
|
||||
id: git
|
||||
shell: bash
|
||||
run: |
|
||||
RELEASE_VERSION="dev-$(date +%s)"
|
||||
echo "::set-output name=image_tag::${RELEASE_VERSION}"
|
||||
echo "Action image_tag=${RELEASE_VERSION}"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Install buildx
|
||||
uses: docker/setup-buildx-action@v2.1.0
|
||||
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
${{ github.repository }}:development
|
||||
ghcr.io/${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
ghcr.io/${{ github.repository }}:development
|
||||
|
||||
@@ -5,7 +5,7 @@ on:
|
||||
types: # This configuration does not affect the page_build event above
|
||||
- created
|
||||
env:
|
||||
PLATFORMS: "linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x"
|
||||
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
||||
|
||||
jobs:
|
||||
build_and_push:
|
||||
@@ -27,23 +27,23 @@ jobs:
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Install buildx
|
||||
uses: docker/setup-buildx-action@v2.0.0
|
||||
uses: docker/setup-buildx-action@v2.1.0
|
||||
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v2.0.0
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2.0.0
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
uses: docker/build-push-action@v3.1.1
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: true
|
||||
|
||||
13
Dockerfile
13
Dockerfile
@@ -1,19 +1,20 @@
|
||||
FROM golang:alpine AS build
|
||||
FROM golang AS build
|
||||
|
||||
ADD . /go/src/app
|
||||
WORKDIR /go/src/app
|
||||
RUN mkdir /endlessh
|
||||
ADD . /endlessh
|
||||
WORKDIR /endlessh
|
||||
RUN go mod tidy
|
||||
RUN go build -o endlessh .
|
||||
|
||||
FROM alpine:latest
|
||||
FROM gcr.io/distroless/base
|
||||
|
||||
LABEL org.opencontainers.image.title=endlessh-go
|
||||
LABEL org.opencontainers.image.description="Endlessh: an SSH tarpit"
|
||||
LABEL org.opencontainers.image.vendor="Shizun Ge"
|
||||
LABEL org.opencontainers.image.licenses=GPLv3
|
||||
|
||||
COPY --from=build /go/src/app/endlessh /usr/bin/endlessh
|
||||
COPY --from=build /endlessh/endlessh /endlessh
|
||||
EXPOSE 2222 2112
|
||||
USER nobody
|
||||
ENTRYPOINT ["/usr/bin/endlessh"]
|
||||
ENTRYPOINT ["/endlessh"]
|
||||
CMD ["-logtostderr", "-v=1"]
|
||||
|
||||
Reference in New Issue
Block a user