Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failover support #65

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8604085
added .gitignore
zombiedk Oct 18, 2023
e91dd34
added failover support
zombiedk Oct 18, 2023
e8e5308
better description
zombiedk Oct 18, 2023
2e1e5e8
moved config to sub dir
zombiedk Oct 24, 2023
a2f8c74
sample files
zombiedk Oct 24, 2023
1dd658f
changed to use ENV vars
zombiedk Oct 24, 2023
c71d319
bug: removed echo
zombiedk Oct 24, 2023
f3791c0
better name
zombiedk Oct 24, 2023
89a80cf
chmod +x
zombiedk Oct 24, 2023
f36d826
added helptext for sample code
zombiedk Oct 24, 2023
be63098
moved back
zombiedk Oct 24, 2023
eb3b8d2
changed from ENV to ARG
zombiedk Oct 24, 2023
7f63c60
changed to build time config
zombiedk Oct 24, 2023
9657dfb
define args in .env
zombiedk Oct 24, 2023
c8852e1
added .env file
zombiedk Oct 24, 2023
0c36cb1
moved to host folder
zombiedk Oct 27, 2023
b3d3897
added jet brains
zombiedk Feb 6, 2024
adcfc24
Merge branch 'sameersbn:master' into master
zombiedk May 8, 2024
a7f8df3
Use Docker volume
Glorforidor Jul 11, 2024
3e887c2
build(deps): bump ubuntu from jammy-20230816 to jammy-20240808
dependabot[bot] Nov 11, 2024
a494a5c
build(deps): bump github/codeql-action from 2 to 3
dependabot[bot] Nov 11, 2024
296c953
build(deps): bump docker/metadata-action from 4 to 5
dependabot[bot] Nov 11, 2024
1e5157d
build(deps): bump docker/setup-buildx-action from 2 to 3
dependabot[bot] Nov 11, 2024
2b15b5e
build(deps): bump docker/build-push-action from 4 to 6
dependabot[bot] Nov 11, 2024
a2cb568
build(deps): bump actions/checkout from 3 to 4
dependabot[bot] Nov 11, 2024
8f90cbf
Merge pull request #1 from SDFIdk/dependabot/docker/ubuntu-jammy-2024…
zombiedk Nov 11, 2024
239b3d0
Merge pull request #2 from SDFIdk/dependabot/github_actions/github/co…
zombiedk Nov 11, 2024
0e0f056
Merge pull request #3 from SDFIdk/dependabot/github_actions/docker/me…
zombiedk Nov 11, 2024
4a09cca
Merge pull request #4 from SDFIdk/dependabot/github_actions/docker/se…
zombiedk Nov 11, 2024
7c835db
Merge pull request #5 from SDFIdk/dependabot/github_actions/docker/bu…
zombiedk Nov 11, 2024
45d7b16
Merge pull request #6 from SDFIdk/dependabot/github_actions/actions/c…
zombiedk Nov 11, 2024
12ecfef
build(deps): bump docker/login-action from 2 to 3
dependabot[bot] Nov 11, 2024
0a98ba5
Merge pull request #7 from SDFIdk/dependabot/github_actions/docker/lo…
zombiedk Nov 11, 2024
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
32 changes: 16 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ jobs:
steps:

- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to ghcr.io registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push to GHCR
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand All @@ -58,10 +58,10 @@ jobs:
steps:

- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to ghcr.io registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -80,10 +80,10 @@ jobs:
steps:

- name: Checkout git repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to ghcr.io registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -104,7 +104,7 @@ jobs:
output: 'results.sarif'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
category: results
Expand All @@ -116,11 +116,11 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
sameersbn/apt-cacher-ng
Expand All @@ -133,33 +133,33 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Github Packages
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build image and push to container registries
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
Expand Down
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Mac/OSX
.DS_Store

# VIM
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Persistent undo
[._]*.un~

# jet brains
.idea
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:jammy-20230816
FROM ubuntu:jammy-20240808

LABEL maintainer="[email protected]"

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,20 @@ Acquire::HTTP::Proxy "http://172.17.0.1:3142";
Acquire::HTTPS::Proxy "false";
```

If you are using a Laptop that is not always able to reach apt-proxy-ng
in order to be able detect where to use the proxy or connect direct, use the these 2 files on the Laptop
```
cp host/01proxy /etc/apt/apt.conf.d/
cp host/apt-proxy-detect.sh /usr/local/bin/
```

Similarly, to use Apt-Cacher NG in you Docker containers add the following line to your `Dockerfile` before any `apt-get` commands.

```dockerfile
RUN echo 'Acquire::HTTP::Proxy "http://172.17.0.1:3142";' >> /etc/apt/apt.conf.d/01proxy \
&& echo 'Acquire::HTTPS::Proxy "false";' >> /etc/apt/apt.conf.d/01proxy
```
if you want to create your own image that has apt-cacher-ng preinstalled look at the sample config in the docker directory

## Logs

Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ services:
ports:
- "3142:3142"
volumes:
- /srv/docker/apt-cacher-ng:/var/cache/apt-cacher-ng
- apt-cacher-ng:/var/cache/apt-cacher-ng

volumes:
apt-cacher-ng:
3 changes: 3 additions & 0 deletions docker/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
UBUNTU_VERSION=latest
APT_CACHER_NG_IP=172.17.0.1
APT_CACHER_NG_PORT=3142
11 changes: 11 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ARG UBUNTU_VERSION=latest
FROM ubuntu:$UBUNTU_VERSION

ARG APT_CACHER_NG_IP
ARG APT_CACHER_NG_PORT=3142

RUN echo "Acquire::HTTP::Proxy \"http://$APT_CACHER_NG_IP:$APT_CACHER_NG_PORT\";" > /etc/apt/apt.conf.d/01proxy \
&& echo "Acquire::HTTPS::Proxy \"false\";" >> /etc/apt/apt.conf.d/01proxy

RUN apt-get update && \
apt-get upgrade -y
11 changes: 11 additions & 0 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.5'

services:
my_server:
image: apt-cacher-ng/ubuntu:${UBUNTU_VERSION}
build:
context: .
args:
UBUNTU_VERSION: '${UBUNTU_VERSION}'
APT_CACHER_NG_IP: '${APT_CACHER_NG_IP}'
APT_CACHER_NG_PORT: '${APT_CACHER_NG_PORT}'
2 changes: 2 additions & 0 deletions host/01proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Acquire::HTTP::Proxy-Auto-Detect "/usr/local/bin/apt-proxy-detect.sh";
Acquire::HTTPS::Proxy "false";
20 changes: 20 additions & 0 deletions host/apt-proxy-detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

if [ -z $APT_CACHER_NG_IP ]
then
echo -n "DIRECT"
exit
fi

if [ -z $APT_CACHER_NG_PORT ]
then
echo -n "DIRECT"
exit
fi

if nc -w1 -z "$APT_CACHER_NG_IP" "$APT_CACHER_NG_PORT" 2> /dev/null
then
echo -n "http://${APT_CACHER_NG_IP}:${APT_CACHER_NG_PORT}"
else
echo -n "DIRECT"
fi