From b8fd319df1cf30c4e0d9f1c11338d8f5aea7b0ab Mon Sep 17 00:00:00 2001 From: Eduardo Folly Date: Thu, 19 Sep 2024 11:38:01 -0300 Subject: [PATCH] Version 0.0.1. --- .github/workflows/main.yml | 72 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 9 +++++ README.md | 2 ++ entrypoint.sh | 18 ++++++++++ version.yaml | 1 + 5 files changed, 102 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100755 entrypoint.sh create mode 100644 version.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..707f922 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,72 @@ +name: CI Build + +on: + push: + branches: [ main ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: write + steps: + - name: Code Checkout + uses: actions/checkout@v4 + + - name: Get Version + run: | + echo "TAGS=latest" >> $GITHUB_ENV + SUFFIX="" + VERSION=$(grep 'version:' version.yaml | cut -c 10-)$SUFFIX + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "REPO=$GITHUB_REPOSITORY" >> $GITHUB_ENV + echo "OWNER=$GITHUB_REPOSITORY_OWNER" >> $GITHUB_ENV + + - name: Check if version is used + run: | + URL=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/${{ env.VERSION }} + echo "$URL" + CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL") + if [ "$CODE" != 404 ]; then + echo "Release '$VERSION' already exists. ($CODE)" + exit 1 + fi + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ env.OWNER }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Docker Build & Push + uses: docker/build-push-action@v6 + with: + push: true + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386 + tags: | + ${{ env.REPO }}:${{ env.VERSION }} + ${{ env.REPO }}:latest + + - name: Creating GitHub Tag + uses: mathieudutour/github-tag-action@v6.2 + with: + custom_tag: ${{ env.VERSION }} + tag_prefix: '' + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ env.VERSION }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf789ec --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:${ALPINE_VERSION:-3.20} + +RUN apk add --update --no-cache busybox-extras envsubst + +COPY entrypoint.sh /usr/local/bin/ + +EXPOSE 23 + +ENTRYPOINT ["entrypoint.sh"] diff --git a/README.md b/README.md index 6e02279..0595615 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ Run: ```shell docker run -d --rm --name telnetd -p 2323:23 \ + -e TELNET_USER=telnetuser \ + -e TELNET_PWD=MySecret123! \ telnetd-container ``` diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..b30c476 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "ENTRYPOINT" + +if [ -z "$TELNET_USER" ]; then + export TELNET_USER="test" +fi + +if [ -z "$TELNET_PWD" ]; then + export TELNET_PWD="VeryDifficult246!" +fi + +adduser -D "$TELNET_USER" + +passwd "$TELNET_USER" -d "$TELNET_PWD" + +### Start telnetd. +/usr/sbin/telnetd -F diff --git a/version.yaml b/version.yaml new file mode 100644 index 0000000..b1465aa --- /dev/null +++ b/version.yaml @@ -0,0 +1 @@ +version: 0.0.1