Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 58 additions & 13 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#new version
name: Docker Image CI

on:
Expand All @@ -7,19 +8,63 @@ on:
branches: [ master ]

jobs:

build:

runs-on: ubuntu-latest
steps:
- run: echo ::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c 1-8)
id: vars
- uses: actions/checkout@v2
- name: Build the Docker image
uses: ilteoood/docker_buildx@master
with:
publish: true
tag: latest,${{ steps.vars.outputs.sha_short }}
imageName: mbartsch/lftp
dockerHubUser: ${{ secrets.DOCKER_USERNAME }}
dockerHubPassword: ${{ secrets.DOCKER_PASSWORD }}
- uses: actions/checkout@v2
with:
fetch-depth: 0

# ── PR build ─────────────────────────────────────────────
- name: Set PR tag
if: github.event_name == 'pull_request'
run: echo "DOCKER_TAGS=beta,DEV-PR-${{ github.event.number }}" >> $GITHUB_ENV

# ── Master build: read latest tag and bump minor ──────────
- name: Get latest semver tag
if: github.event_name == 'push'
id: get_tag
run: |
# Fetch all tags
git fetch --tags

# Find the latest vMAJOR.MINOR tag (ignore anything else)
LATEST=$(git tag --list 'v*.*' \
| sort -t. -k1,1V -k2,2n \
| tail -n1)

if [ -z "$LATEST" ]; then
LATEST="v1.0"
fi

echo "Latest tag: $LATEST"

MAJOR=$(echo "$LATEST" | cut -d. -f1 | tr -d 'v')
MINOR=$(echo "$LATEST" | cut -d. -f2)
NEW_MINOR=$((MINOR + 1))
NEW_TAG="v${MAJOR}.${NEW_MINOR}"

echo "New tag: $NEW_TAG"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
echo "DOCKER_TAGS=latest,$NEW_TAG" >> $GITHUB_ENV

- name: Create and push git tag
if: github.event_name == 'push'
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag "${{ env.NEW_TAG }}"
git push origin "${{ env.NEW_TAG }}"

# ── Build & push ──────────────────────────────────────────
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: mbartsch/lftp
tags: ${{ env.DOCKER_TAGS }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
platforms: linux/amd64,linux/arm64
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM alpine:latest
MAINTAINER Marcelo Bartsch <marcelo@bartsch.cl>

RUN apk --no-cache add lftp ca-certificates openssh

ENTRYPOINT [ "/usr/bin/lftp" ]
ADD init.sh /
RUN apk --no-cache add lftp ca-certificates openssh su-exec && chmod +x /init.sh
RUN chmod +x /init.sh
ENTRYPOINT [ "/init.sh","/usr/bin/lftp" ]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ A Simple Docker Container based on alpine linux to run LFTP
to run just use

docker run --rm -v /download_folder:/mnt mbartsch/lftp

if youi need to run lftp as a different user , for example for sftp, you need to specify RUN_UID as an environment variable

docker run -e RUN_UID=999 --rm -v /download_folder:/mnt mbartsch/lftp
7 changes: 7 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
if [ ! -z ${RUN_UID} ] ; then
adduser -u ${RUN_UID} -D abc123
su-exec abc123 $@
else
exec $@
fi
Loading