mirror of
https://github.com/EvilFreelancer/docker-routeros.git
synced 2025-08-20 01:09:29 +02:00
Compare commits
No commits in common. "master" and "7.14.2" have entirely different histories.
10 changed files with 188 additions and 89 deletions
69
.github/workflows/build-and-push.yml
vendored
69
.github/workflows/build-and-push.yml
vendored
|
@ -1,69 +0,0 @@
|
||||||
name: Check for new RouterOS versions, build and push containers
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 0 * * *' # Every day at midnight
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check-and-build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: sudo apt-get install -y curl jq
|
|
||||||
|
|
||||||
- name: Get latest RouterOS version
|
|
||||||
id: get_routeros_version
|
|
||||||
run: |
|
|
||||||
VERSION=$(
|
|
||||||
curl https://mikrotik.com/download/archive -o - 2>/dev/null | \
|
|
||||||
grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | \
|
|
||||||
sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' | \
|
|
||||||
grep -i c-stable | \
|
|
||||||
sed -r 's/\#c-stable-v//gi' | \
|
|
||||||
sed -r 's/_/\./gi' | \
|
|
||||||
sort -V | \
|
|
||||||
tail -n 1
|
|
||||||
)
|
|
||||||
|
|
||||||
echo "Latest RouterOS version: $VERSION"
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Get Docker Hub tags
|
|
||||||
id: docker_hub_tags
|
|
||||||
run: |
|
|
||||||
OWNER="evilfreelancer"
|
|
||||||
REPO="docker-routeros"
|
|
||||||
URL="https://registry.hub.docker.com/v2/repositories/${OWNER}/${REPO}/tags/"
|
|
||||||
TAGS=$(curl -s "$URL" | jq -r '.results[].name' | grep -v "latest")
|
|
||||||
echo "tags=$(echo $TAGS | tr '\n' ' ')" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Build and test if new version
|
|
||||||
if: ${{ !contains(steps.docker_hub_tags.outputs.tags, steps.get_routeros_version.outputs.version) }}
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.get_routeros_version.outputs.version }}"
|
|
||||||
OWNER="evilfreelancer"
|
|
||||||
REPO="docker-routeros"
|
|
||||||
|
|
||||||
# Set up Docker Buildx
|
|
||||||
docker buildx create --use --name routeros_builder
|
|
||||||
|
|
||||||
# Build and push images
|
|
||||||
docker buildx build --push \
|
|
||||||
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
||||||
--tag $OWNER/$REPO:$VERSION \
|
|
||||||
--tag $OWNER/$REPO:latest \
|
|
||||||
--build-arg ROUTEROS_VERSION=$VERSION .
|
|
||||||
|
|
||||||
- name: Skip build
|
|
||||||
if: ${{ contains(steps.docker_hub_tags.outputs.tags, steps.get_routeros_version.outputs.version) }}
|
|
||||||
run: echo "Version ${{ steps.get_routeros_version.outputs.version }} already exists. Skipping build."
|
|
34
.github/workflows/cd.yml
vendored
Normal file
34
.github/workflows/cd.yml
vendored
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: "Build docker image and push to DockerHub when a tag is pushed"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: "Build images"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Docker metadata from Git
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: evilfreelancer/docker-routeros
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: ${{ !env.ACT }}
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build with Docker
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: ${{ !env.ACT }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
47
.github/workflows/ci.yml
vendored
Normal file
47
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
name: "Continuous Integration Tests"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
workflow_call:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: "Build & Test images"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download docker-compose when using act
|
||||||
|
if: env.ACT
|
||||||
|
run: |
|
||||||
|
sudo curl -L "https://github.com/docker/compose/releases/download/v2.24.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||||
|
sudo chmod +x /usr/local/bin/docker-compose
|
||||||
|
|
||||||
|
- name: Test with Docker
|
||||||
|
run: |
|
||||||
|
# start the container
|
||||||
|
docker-compose -f docker-compose.dist.yml up --build -d routeros-local
|
||||||
|
# wait for the container to start
|
||||||
|
sleep 5
|
||||||
|
DOCKERID=$(docker ps --format '{{.ID}}.{{.Names}}.{{.Image}}'|grep evilfreelancer/docker-routeros|cut -f 1 -d '.')
|
||||||
|
echo "Watching $DOCKERID for Mikrotik login..."
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
if docker logs "$DOCKERID" 2>&1|grep 'MikroTik'
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
echo "Not found yet, sleeping..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
# display logs
|
||||||
|
echo "Container logs:"
|
||||||
|
docker logs "$DOCKERID"
|
||||||
|
# download resource and check platform is Mikrotik
|
||||||
|
curl --retry 12 --retry-all-errors -k -u admin: http://127.0.0.1:7777/rest/system/resource | jq .platform |grep -i mikrotik
|
||||||
|
|
||||||
|
- name: Stop container
|
||||||
|
run: docker-compose -f docker-compose.dist.yml down
|
14
.github/workflows/lint.yml
vendored
Normal file
14
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: Lint github-action
|
||||||
|
|
||||||
|
on: [ 'pull_request' ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Lint
|
||||||
|
uses: docker://rhysd/actionlint:1.6.26
|
||||||
|
with:
|
||||||
|
args: -color
|
47
.github/workflows/pr.yml
vendored
Normal file
47
.github/workflows/pr.yml
vendored
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
name: "Check for update on Mikrotik website and generate a PR if necessary"
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 4 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
routeros:
|
||||||
|
name: "Build & Test images"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: '1'
|
||||||
|
|
||||||
|
- name: Check new release
|
||||||
|
id: check_release
|
||||||
|
run: |
|
||||||
|
LAST_MIKROTIK_RELEASE=$( curl https://mikrotik.com/download/archive -o - 2>/dev/null | grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' | grep -i c-stable | sed -r 's/\#c-stable-v//gi'|sed -r 's/_/\./gi'|sort -V|tail -n 1)
|
||||||
|
NEW_TAG=$(grep "ROUTEROS_VERSION=\"" Dockerfile |cut -d "\"" -f 2)
|
||||||
|
if [ "$LAST_MIKROTIK_RELEASE" != "$NEW_TAG" ]; then
|
||||||
|
echo "New version found: $LAST_MIKROTIK_RELEASE"
|
||||||
|
echo "Current version: $NEW_TAG"
|
||||||
|
echo "release=$LAST_MIKROTIK_RELEASE" > "$GITHUB_OUTPUT"
|
||||||
|
echo "new=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "No new version found"
|
||||||
|
echo "new=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Edit Dockerfile
|
||||||
|
if: ${{ steps.check_release.outputs.new == 'true' }}
|
||||||
|
run: |
|
||||||
|
sed -r "s/(ROUTEROS_VERSION=\")(.*)(\")/\1${{ steps.check_release.outputs.release }}\3/g" -i Dockerfile
|
||||||
|
git diff
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: ${{ steps.check_release.outputs.new == 'true' && !env.ACT }}
|
||||||
|
uses: peter-evans/create-pull-request@v6
|
||||||
|
with:
|
||||||
|
commit-message: "Update RouterOS version to ${{ steps.check_release.outputs.release }}"
|
||||||
|
committer: "GitHub Actions<github-actions@users.noreply.github.com>"
|
||||||
|
body: 'Created by Github action'
|
||||||
|
title: 'Update RouterOS version to ${{ steps.check_release.outputs.release }}'
|
||||||
|
branch: update-routeros
|
38
.github/workflows/tag.yml
vendored
Normal file
38
.github/workflows/tag.yml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
name: "Tag master with new version of RouterOS when CI pass"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call_test:
|
||||||
|
uses: EvilFreelancer/docker-routeros/.github/workflows/ci.yml@master
|
||||||
|
|
||||||
|
tag:
|
||||||
|
name: "Add a tag to git"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
needs: call_test
|
||||||
|
if: always() && needs.call_test.result == 'success'
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: '0'
|
||||||
|
|
||||||
|
- name: Add new tag on git
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
NEW_TAG=$(grep 'ROUTEROS_VERSION="' Dockerfile |cut -d '"' -f 2)
|
||||||
|
git config user.name 'GitHub Actions'
|
||||||
|
git config user.email 'github-actions@users.noreply.github.com'
|
||||||
|
git tag "$NEW_TAG"
|
||||||
|
echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Push new tag to git
|
||||||
|
if: ${{ !env.ACT }}
|
||||||
|
run: git push origin ${{ steps.tag.outputs.new_tag }}
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
/.idea/
|
/.idea/
|
||||||
/*.vdi
|
/*.vdi
|
||||||
/docker-compose.yml
|
/docker-compose.yml
|
||||||
build.txt
|
|
17
Dockerfile
17
Dockerfile
|
@ -1,4 +1,4 @@
|
||||||
FROM alpine:3.22.1
|
FROM alpine:3.19.1
|
||||||
|
|
||||||
# For access via VNC
|
# For access via VNC
|
||||||
EXPOSE 5900
|
EXPOSE 5900
|
||||||
|
@ -9,8 +9,6 @@ EXPOSE 1194 1701 1723 1812/udp 1813/udp 21 22 23 443 4500/udp 50 500/udp 51 2021
|
||||||
# Change work dir (it will also create this folder if is not exist)
|
# Change work dir (it will also create this folder if is not exist)
|
||||||
WORKDIR /routeros
|
WORKDIR /routeros
|
||||||
|
|
||||||
RUN mkdir -p /routeros_source
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN set -xe \
|
RUN set -xe \
|
||||||
&& apk add --no-cache --update \
|
&& apk add --no-cache --update \
|
||||||
|
@ -19,17 +17,16 @@ RUN set -xe \
|
||||||
bridge-utils iptables jq bash python3
|
bridge-utils iptables jq bash python3
|
||||||
|
|
||||||
# Environments which may be change
|
# Environments which may be change
|
||||||
ARG ROUTEROS_VERSION
|
ENV ROUTEROS_VERSION="7.14.2"
|
||||||
ENV ROUTEROS_VERSION=${ROUTEROS_VERSION}
|
|
||||||
ENV ROUTEROS_IMAGE="chr-${ROUTEROS_VERSION}.vdi"
|
ENV ROUTEROS_IMAGE="chr-${ROUTEROS_VERSION}.vdi"
|
||||||
ENV ROUTEROS_PATH="https://cdn.mikrotik.com/routeros/${ROUTEROS_VERSION}/${ROUTEROS_IMAGE}.zip"
|
ENV ROUTEROS_PATH="https://cdn.mikrotik.com/routeros/${ROUTEROS_VERSION}/${ROUTEROS_IMAGE}.zip"
|
||||||
|
|
||||||
# Download VDI image from remote site
|
# Download VDI image from remote site
|
||||||
RUN wget "$ROUTEROS_PATH" -O "/routeros_source/${ROUTEROS_IMAGE}.zip" && \
|
RUN wget "$ROUTEROS_PATH" -O "/routeros/${ROUTEROS_IMAGE}.zip" && \
|
||||||
unzip "/routeros_source/${ROUTEROS_IMAGE}.zip" -d "/routeros_source" && \
|
unzip "/routeros/${ROUTEROS_IMAGE}.zip" -d "/routeros" && \
|
||||||
rm -f "/routeros_source/${ROUTEROS_IMAGE}.zip"
|
rm -f "/routeros/${ROUTEROS_IMAGE}.zip"
|
||||||
|
|
||||||
# Copy script to routeros folder
|
# Copy script to routeros folder
|
||||||
ADD ["./scripts", "/routeros_source"]
|
ADD ["./scripts", "/routeros"]
|
||||||
|
|
||||||
ENTRYPOINT ["/routeros_source/entrypoint.sh"]
|
ENTRYPOINT ["/routeros/entrypoint.sh"]
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ ! -e "/routeros/generate-dhcpd-conf.py" ]]; then
|
|
||||||
|
|
||||||
cp -r /routeros_source/. /routeros
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
cd /routeros
|
|
||||||
|
|
||||||
QEMU_BRIDGE_ETH1='qemubr1'
|
QEMU_BRIDGE_ETH1='qemubr1'
|
||||||
default_dev1='eth0'
|
default_dev1='eth0'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue