mirror of
https://github.com/chaifeng/ufw-docker.git
synced 2025-05-10 21:48:30 +02:00
Compare commits
10 commits
221002-leg
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
1a51b59cf8 | ||
|
5908cde296 | ||
|
8f9335326f | ||
|
c9547cb4ec | ||
|
9474084f3f | ||
|
1fa425bf17 | ||
|
3d6896cdd1 | ||
|
6cdd4dfd2f | ||
|
17e6047590 | ||
|
a273ac9d51 |
6 changed files with 76 additions and 19 deletions
35
.github/workflows/build.yml
vendored
Normal file
35
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
name: Build Images
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Log into DockerHub
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ github.actor }}/ufw-docker-agent
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
platforms: linux/amd64,linux/arm64/v8
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
|
@ -1,6 +1,6 @@
|
||||||
FROM ubuntu:20.04
|
FROM ubuntu:24.04
|
||||||
|
|
||||||
ARG docker_version="20.10.17"
|
ARG docker_version="27.3.1"
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
|
@ -12,8 +12,7 @@ RUN apt-get update \
|
||||||
| tee /etc/apt/sources.list.d/docker.list > /dev/null \
|
| tee /etc/apt/sources.list.d/docker.list > /dev/null \
|
||||||
&& apt-get update \
|
&& apt-get update \
|
||||||
&& apt-get install -y --no-install-recommends locales ufw \
|
&& apt-get install -y --no-install-recommends locales ufw \
|
||||||
&& ( apt-get install -y --no-install-recommends "docker-ce=5:${docker_version}~*" || \
|
&& apt-get install -y --no-install-recommends "docker-ce=$(apt-cache madison docker-ce | grep -m1 -F "${docker_version}" | cut -d'|' -f2 | tr -d '[[:blank:]]')" \
|
||||||
apt-get install -y --no-install-recommends "docker-ce=${docker_version}~*" ) \
|
|
||||||
&& locale-gen en_US.UTF-8 \
|
&& locale-gen en_US.UTF-8 \
|
||||||
&& apt-get clean autoclean \
|
&& apt-get clean autoclean \
|
||||||
&& apt-get autoremove --yes \
|
&& apt-get autoremove --yes \
|
||||||
|
|
15
Vagrantfile
vendored
15
Vagrantfile
vendored
|
@ -6,16 +6,15 @@
|
||||||
ENV['VAGRANT_NO_PARALLEL']="true"
|
ENV['VAGRANT_NO_PARALLEL']="true"
|
||||||
|
|
||||||
Vagrant.configure('2') do |config|
|
Vagrant.configure('2') do |config|
|
||||||
|
|
||||||
docker_version = "20.10.17"
|
|
||||||
|
|
||||||
ubuntu_version = File.readlines("Dockerfile").filter { |line|
|
ubuntu_version = File.readlines("Dockerfile").filter { |line|
|
||||||
line.start_with?("FROM ")
|
line.start_with?("FROM ")
|
||||||
}.first.match(/\d\d\.\d\d/)[0]
|
}.first.match(/\d\d\.\d\d/)[0]
|
||||||
|
|
||||||
config.vm.box = "chaifeng/ubuntu-#{ubuntu_version}-docker-#{docker_version}#{(`uname -m`.strip == "arm64")?"-arm64":""}"
|
docker_version = File.readlines("Dockerfile").filter { |line|
|
||||||
|
line.start_with?("ARG docker_version=")
|
||||||
|
}.first.match(/"([\d\.]+)"/)[1]
|
||||||
|
|
||||||
#config.vm.box = "chaifeng/ubuntu-20.04-docker-20.10.17#{(`uname -m`.strip == "arm64")?"-arm64":""}"
|
config.vm.box = "chaifeng/ubuntu-#{ubuntu_version}-docker-#{docker_version}"
|
||||||
|
|
||||||
config.vm.provider 'virtualbox' do |vb|
|
config.vm.provider 'virtualbox' do |vb|
|
||||||
vb.memory = '1024'
|
vb.memory = '1024'
|
||||||
|
@ -178,6 +177,7 @@ DOCKERFILE
|
||||||
|
|
||||||
ufw-docker service allow public_service 80/tcp
|
ufw-docker service allow public_service 80/tcp
|
||||||
|
|
||||||
|
docker service inspect "public_multiport" ||
|
||||||
docker service create --name "public_multiport" \
|
docker service create --name "public_multiport" \
|
||||||
--publish "40080:80" --publish "47000:7000" --publish "48080:8080" \
|
--publish "40080:80" --publish "47000:7000" --publish "48080:8080" \
|
||||||
--env name="public_multiport" --replicas 3 #{private_registry}/chaifeng/hostname-webapp
|
--env name="public_multiport" --replicas 3 #{private_registry}/chaifeng/hostname-webapp
|
||||||
|
@ -202,6 +202,11 @@ DOCKERFILE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config.vm.define "node-internal" do |node|
|
||||||
|
node.vm.hostname = "node-internal"
|
||||||
|
node.vm.network "private_network", ip: "#{ip_prefix}.142"
|
||||||
|
end
|
||||||
|
|
||||||
config.vm.define "external" do |external|
|
config.vm.define "external" do |external|
|
||||||
external.vm.hostname = "external"
|
external.vm.hostname = "external"
|
||||||
external.vm.network "private_network", ip: "#{ip_prefix}.127"
|
external.vm.network "private_network", ip: "#{ip_prefix}.127"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 447edb60db232d3dbc2267f37c49bd7a070cc83d
|
Subproject commit 27885eb79c11e4652dede994c886ae5f9e30994f
|
|
@ -15,7 +15,10 @@ source "$working_dir"/bach/bach.sh
|
||||||
@mock iptables --version
|
@mock iptables --version
|
||||||
@mocktrue grep -F '(legacy)'
|
@mocktrue grep -F '(legacy)'
|
||||||
|
|
||||||
@ignore remove_blank_lines
|
@mocktrue docker -v
|
||||||
|
@mock docker -v === @stdout Docker version 0.0.0, build dummy
|
||||||
|
|
||||||
|
@mockpipe remove_blank_lines
|
||||||
@ignore echo
|
@ignore echo
|
||||||
@ignore err
|
@ignore err
|
||||||
|
|
||||||
|
@ -98,6 +101,17 @@ test-ufw-is-disabled-assert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
test-docker-is-installed() {
|
||||||
|
@mockfalse docker -v
|
||||||
|
|
||||||
|
ufw-docker
|
||||||
|
}
|
||||||
|
test-docker-is-installed-assert() {
|
||||||
|
die "Docker executable not found."
|
||||||
|
ufw-docker--help
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
test-ufw-docker-status() {
|
test-ufw-docker-status() {
|
||||||
ufw-docker status
|
ufw-docker status
|
||||||
}
|
}
|
||||||
|
@ -451,7 +465,7 @@ test-ufw-docker--instance-name-found-a-name() {
|
||||||
}
|
}
|
||||||
test-ufw-docker--instance-name-found-a-name-assert() {
|
test-ufw-docker--instance-name-found-a-name-assert() {
|
||||||
docker inspect --format="{{.Name}}" foo
|
docker inspect --format="{{.Name}}" foo
|
||||||
echo -n foo
|
@dryrun echo -n foo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -543,7 +557,7 @@ test-ufw-docker--list-number-assert() {
|
||||||
|
|
||||||
test-ufw-docker--delete-empty-result() {
|
test-ufw-docker--delete-empty-result() {
|
||||||
@mock ufw-docker--list-number webapp 80 tcp === @stdout ""
|
@mock ufw-docker--list-number webapp 80 tcp === @stdout ""
|
||||||
@mock sort -rn
|
@mockpipe sort -rn
|
||||||
|
|
||||||
load-ufw-docker-function ufw-docker--delete
|
load-ufw-docker-function ufw-docker--delete
|
||||||
ufw-docker--delete webapp 80 tcp
|
ufw-docker--delete webapp 80 tcp
|
||||||
|
@ -555,7 +569,7 @@ test-ufw-docker--delete-empty-result-assert() {
|
||||||
|
|
||||||
test-ufw-docker--delete-all() {
|
test-ufw-docker--delete-all() {
|
||||||
@mock ufw-docker--list-number webapp 80 tcp === @stdout 5 8 9
|
@mock ufw-docker--list-number webapp 80 tcp === @stdout 5 8 9
|
||||||
@mock sort -rn
|
@mockpipe sort -rn
|
||||||
|
|
||||||
load-ufw-docker-function ufw-docker--delete
|
load-ufw-docker-function ufw-docker--delete
|
||||||
ufw-docker--delete webapp 80 tcp
|
ufw-docker--delete webapp 80 tcp
|
||||||
|
|
|
@ -5,13 +5,13 @@ set -euo pipefail
|
||||||
LANG=en_US.UTF-8
|
LANG=en_US.UTF-8
|
||||||
LANGUAGE=en_US:
|
LANGUAGE=en_US:
|
||||||
LC_ALL=en_US.UTF-8
|
LC_ALL=en_US.UTF-8
|
||||||
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
PATH="/bin:/usr/bin:/sbin:/usr/sbin:/snap/bin/"
|
||||||
|
|
||||||
GREP_REGEXP_INSTANCE_NAME="[-_.[:alnum:]]\\+"
|
GREP_REGEXP_INSTANCE_NAME="[-_.[:alnum:]]\\+"
|
||||||
DEFAULT_PROTO=tcp
|
DEFAULT_PROTO=tcp
|
||||||
|
|
||||||
ufw_docker_agent=ufw-docker-agent
|
ufw_docker_agent=ufw-docker-agent
|
||||||
ufw_docker_agent_image="${UFW_DOCKER_AGENT_IMAGE:-chaifeng/${ufw_docker_agent}:221002-legacy}"
|
ufw_docker_agent_image="${UFW_DOCKER_AGENT_IMAGE:-chaifeng/${ufw_docker_agent}:221002-nf_tables}"
|
||||||
|
|
||||||
if [[ "${ufw_docker_agent_image}" = *-@(legacy|nf_tables) ]]; then
|
if [[ "${ufw_docker_agent_image}" = *-@(legacy|nf_tables) ]]; then
|
||||||
if iptables --version | grep -F '(legacy)' &>/dev/null; then
|
if iptables --version | grep -F '(legacy)' &>/dev/null; then
|
||||||
|
@ -424,6 +424,10 @@ if ! ufw status 2>/dev/null | grep -Fq "Status: active" ; then
|
||||||
die "UFW is disabled or you are not root user, or mismatched iptables legacy/nf_tables, current $(iptables --version)"
|
die "UFW is disabled or you are not root user, or mismatched iptables legacy/nf_tables, current $(iptables --version)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! docker -v &> /dev/null; then
|
||||||
|
die "Docker executable not found."
|
||||||
|
fi
|
||||||
|
|
||||||
ufw_action="${1:-help}"
|
ufw_action="${1:-help}"
|
||||||
|
|
||||||
case "$ufw_action" in
|
case "$ufw_action" in
|
||||||
|
|
Loading…
Add table
Reference in a new issue