dockerized go-apt-cacher with config for internal use

This commit is contained in:
Jeffrey Paul 2020-10-03 01:06:52 -07:00
parent d9e17716a1
commit 589cc2fdaa
4 changed files with 80 additions and 1 deletions

12
.drone.yml Normal file
View File

@ -0,0 +1,12 @@
kind: pipeline
name: test-docker-build
steps:
- name: test-docker-build
image: plugins/docker
settings:
repo: sneak/go-apt-cacher
dry_run: true
tags:
- ${DRONE_COMMIT_SHA}
- ${DRONE_BRANCH}

View File

@ -1,3 +1,23 @@
FROM ubuntu:focal
FROM golang:1.15-buster AS builder
WORKDIR /usr/local/src
#RUN apt update && apt install -y git
RUN git clone https://github.com/cybozu-go/aptutil.git && \
cd aptutil && \
git checkout 3f82d83844818cdd6a6d7dca3eca0f76d8a3fce5
WORKDIR /usr/local/src/aptutil
RUN go mod download
WORKDIR /usr/local/src/aptutil/cmd/go-apt-cacher
RUN go build
RUN find .
FROM debian:buster-slim AS final
COPY --from=builder /usr/local/src/aptutil/cmd/go-apt-cacher/go-apt-cacher /usr/local/bin/go-apt-cacher
ADD ./go-apt-cacher.toml /etc/go-apt-cacher.toml
RUN chmod ugoa+rx /usr/local/bin/* && \
mkdir -p /var/spool/go-apt-cacher && \
chown nobody:nogroup /var/spool/go-apt-cacher
USER nobody:nogroup
ENTRYPOINT ["/usr/local/bin/go-apt-cacher"]

5
Makefile Normal file
View File

@ -0,0 +1,5 @@
docker:
docker build --progress plain -t sneak/go-apt-cacher .
run:
docker run -p 8080:8080 -ti sneak/go-apt-cacher

42
go-apt-cacher.toml Normal file
View File

@ -0,0 +1,42 @@
# listen_address is the listening address of go-apt-cacher.
# Default is ":3142".
listen_address = ":8080"
# Interval to check updates for Release/InRelease files.
# Default: 600 seconds
check_interval = 600
# Cache period for bad HTTP response statuses.
# Default: 3 seconds
cache_period = 3
# Directory for meta data files.
# The directory owner must be the same as the process owner of go-apt-cacher.
meta_dir = "/var/spool/go-apt-cacher/meta"
# Directory for non-meta data files.
# This directory must be different from meta_dir.
# The directory owner must be the same as the process owner of go-apt-cacher.
cache_dir = "/var/spool/go-apt-cacher/cache"
# Capacity for cache_dir.
# Default: 1 GiB
cache_capacity = 10
# Maximum concurrent connections for an upstream server.
# Setting this 0 disables limit on the number of connections.
# Default: 10
max_conns = 20
# log specifies logging configurations.
# Details at https://godoc.org/github.com/cybozu-go/well#LogConfig
[log]
#filename = "/var/log/go-apt-cacher.log"
level = "info"
format = "plain"
# mapping declares which prefix maps to a Debian repository URL.
# prefix must match this regexp: ^[a-z0-9._-]+$
[mapping]
ubuntu = "http://archive.ubuntu.com/ubuntu"
security = "http://security.ubuntu.com/ubuntu"