mirror of
https://github.com/zardus/ctf-tools
synced 2024-12-04 18:29:26 +00:00
Updated Dockerfiles, added script to quickly run manage-tools in a container for testing
* Dockerfile updates * Ubuntus now use apt-get-install wrapper to not leave package lists in the container * Copy uncommited manage-tools, etc. scripts into container, which is good for manual testing. * Remove dependency on virtualenvwrapper for Ubuntus and Fedora * `ctf-tools-test-action` to quickly test something for another distribution in a docker container, e.g. `ctf-tools-test-action -d fedora -s -v reinstall qemu`
This commit is contained in:
parent
dd4f08ffdb
commit
ec75e3d081
8 changed files with 160 additions and 20 deletions
13
.docker/apt-get-install
Executable file
13
.docker/apt-get-install
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh -e
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
# update the package lists etc.
|
||||
apt-get -q update
|
||||
# this is actually against docker recommendations... But we'll do it anyway in
|
||||
# case our base image was not yet updated.
|
||||
apt-get dist-upgrade -y --no-install-recommends --auto-remove
|
||||
# finally install the package
|
||||
apt-get install -y --no-install-recommends --auto-remove "$@"
|
||||
# remove the package lists and apt-get metadata, such that the docker image
|
||||
# layer stays small
|
||||
apt-get -q clean
|
||||
rm -rf /var/lib/apt/lists/*
|
|
@ -1,2 +1,4 @@
|
|||
*
|
||||
!.git
|
||||
!.docker
|
||||
!bin/
|
||||
|
|
33
Dockerfile
33
Dockerfile
|
@ -1,25 +1,38 @@
|
|||
from ubuntu:trusty
|
||||
maintainer yans@yancomm.net
|
||||
FROM ubuntu:trusty
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential libtool g++ gcc \
|
||||
# wrapper script for apt-get
|
||||
COPY .docker/apt-get-install /usr/local/bin/apt-get-install
|
||||
RUN chmod +x /usr/local/bin/apt-get-install
|
||||
|
||||
RUN apt-get-install build-essential libtool g++ gcc \
|
||||
texinfo curl wget automake autoconf python python-dev git subversion \
|
||||
unzip virtualenvwrapper sudo
|
||||
unzip virtualenvwrapper sudo git virtualenvwrapper
|
||||
|
||||
RUN useradd -m ctf
|
||||
RUN echo "ctf ALL=NOPASSWD: ALL" > /etc/sudoers.d/ctf
|
||||
|
||||
COPY .git /home/ctf/tools/.git
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
RUN echo "ctf ALL=NOPASSWD: ALL" > /etc/sudoers.d/ctf
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git virtualenvwrapper
|
||||
|
||||
# git checkout of the files
|
||||
USER ctf
|
||||
|
||||
WORKDIR /home/ctf/tools
|
||||
RUN git checkout .
|
||||
|
||||
# add non-commited scripts
|
||||
USER root
|
||||
COPY bin/manage-tools /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-pip /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate3 /home/ctf/tools/bin/
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
# finally run ctf-tools setup
|
||||
USER ctf
|
||||
RUN bin/manage-tools -s setup
|
||||
RUN bin/ctf-tools-pip install appdirs
|
||||
RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
#RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
RUN echo 'source $(which ctf-tools-venv-activate)' >> /home/ctf/.bashrc
|
||||
|
||||
WORKDIR /home/ctf
|
||||
CMD bash -i
|
||||
|
|
|
@ -38,6 +38,16 @@ USER ctf
|
|||
|
||||
WORKDIR /home/ctf/tools
|
||||
RUN git checkout .
|
||||
|
||||
# add non-commited scripts
|
||||
USER root
|
||||
COPY bin/manage-tools /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-pip /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate3 /home/ctf/tools/bin/
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
USER ctf
|
||||
RUN bin/manage-tools -s setup
|
||||
RUN echo 'source $(which virtualenvwrapper.sh)' >> ~/.zshrc
|
||||
RUN echo 'workon ctftools' >> ~/.zshrc
|
||||
|
|
38
Dockerfile.artful
Normal file
38
Dockerfile.artful
Normal file
|
@ -0,0 +1,38 @@
|
|||
FROM ubuntu:artful
|
||||
|
||||
# wrapper script for apt-get
|
||||
COPY .docker/apt-get-install /usr/local/bin/apt-get-install
|
||||
RUN chmod +x /usr/local/bin/apt-get-install
|
||||
|
||||
RUN apt-get-install build-essential libtool g++ gcc \
|
||||
texinfo curl wget automake autoconf python python-dev git subversion \
|
||||
unzip virtualenvwrapper sudo git virtualenvwrapper
|
||||
|
||||
RUN useradd -m ctf
|
||||
RUN echo "ctf ALL=NOPASSWD: ALL" > /etc/sudoers.d/ctf
|
||||
|
||||
COPY .git /home/ctf/tools/.git
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
# git checkout of the files
|
||||
USER ctf
|
||||
WORKDIR /home/ctf/tools
|
||||
RUN git checkout .
|
||||
|
||||
# add non-commited scripts
|
||||
USER root
|
||||
COPY bin/manage-tools /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-pip /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate3 /home/ctf/tools/bin/
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
# finally run ctf-tools setup
|
||||
USER ctf
|
||||
RUN bin/manage-tools -s setup
|
||||
RUN bin/ctf-tools-pip install appdirs
|
||||
#RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
RUN echo 'source $(which ctf-tools-venv-activate)' >> /home/ctf/.bashrc
|
||||
|
||||
WORKDIR /home/ctf
|
||||
#CMD bash -i
|
|
@ -11,9 +11,19 @@ USER ctf
|
|||
|
||||
WORKDIR /home/ctf/tools
|
||||
RUN git checkout .
|
||||
|
||||
# add non-commited scripts
|
||||
USER root
|
||||
COPY bin/manage-tools /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-pip /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate3 /home/ctf/tools/bin/
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
USER ctf
|
||||
RUN bin/manage-tools -s setup
|
||||
RUN bin/ctf-tools-pip install appdirs
|
||||
RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
RUN echo 'source $(which ctf-tools-venv-activate)' >> /home/ctf/.bashrc
|
||||
|
||||
WORKDIR /home/ctf
|
||||
CMD bash -i
|
||||
|
|
|
@ -1,25 +1,38 @@
|
|||
from ubuntu:xenial
|
||||
maintainer yans@yancomm.net
|
||||
|
||||
RUN apt-get update && apt-get install -y build-essential libtool g++ gcc \
|
||||
# wrapper script for apt-get
|
||||
COPY .docker/apt-get-install /usr/local/bin/apt-get-install
|
||||
RUN chmod +x /usr/local/bin/apt-get-install
|
||||
|
||||
RUN apt-get-install build-essential libtool g++ gcc \
|
||||
texinfo curl wget automake autoconf python python-dev git subversion \
|
||||
unzip virtualenvwrapper sudo
|
||||
unzip virtualenvwrapper sudo git virtualenvwrapper
|
||||
|
||||
RUN useradd -m ctf
|
||||
RUN echo "ctf ALL=NOPASSWD: ALL" > /etc/sudoers.d/ctf
|
||||
|
||||
COPY .git /home/ctf/tools/.git
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
RUN echo "ctf ALL=NOPASSWD: ALL" > /etc/sudoers.d/ctf
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install git virtualenvwrapper
|
||||
|
||||
# git checkout of the files
|
||||
USER ctf
|
||||
|
||||
WORKDIR /home/ctf/tools
|
||||
RUN git checkout .
|
||||
|
||||
# add non-commited scripts
|
||||
USER root
|
||||
COPY bin/manage-tools /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-pip /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate /home/ctf/tools/bin/
|
||||
COPY bin/ctf-tools-venv-activate3 /home/ctf/tools/bin/
|
||||
RUN chown -R ctf.ctf /home/ctf/tools
|
||||
|
||||
# finally run ctf-tools setup
|
||||
USER ctf
|
||||
RUN bin/manage-tools -s setup
|
||||
RUN bin/ctf-tools-pip install appdirs
|
||||
RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
#RUN echo "workon ctftools" >> /home/ctf/.bashrc
|
||||
RUN echo 'source $(which ctf-tools-venv-activate)' >> /home/ctf/.bashrc
|
||||
|
||||
WORKDIR /home/ctf
|
||||
CMD bash -i
|
||||
|
|
41
bin/ctf-tools-test-action
Executable file
41
bin/ctf-tools-test-action
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
function usage()
|
||||
{
|
||||
cat <<END
|
||||
Usage: $(basename $0) [-d distribution] <manage-tools parameters...>
|
||||
|
||||
Run a manage-tools actions inside of a docker container, with the current
|
||||
ctf-tools repository mounted into the container. This is primarily useful for
|
||||
testing uncommited changes to a tool.
|
||||
|
||||
END
|
||||
}
|
||||
|
||||
|
||||
CTFTOOLS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../"
|
||||
|
||||
DOCKER_DIST=""
|
||||
DOCKER_CONTAINER="ctftools${DOCKER_DIST}"
|
||||
|
||||
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$1" == "-d" ]]; then
|
||||
DOCKER_DIST=".$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
pushd $CTFTOOLS_DIR >/dev/null
|
||||
set -x
|
||||
sudo docker build \
|
||||
-t "$DOCKER_CONTAINER" \
|
||||
-f "Dockerfile${DOCKER_DIST}" \
|
||||
.
|
||||
|
||||
sudo docker run --rm -it \
|
||||
-v $CTFTOOLS_DIR:/home/ctf/tools:z \
|
||||
"$DOCKER_CONTAINER" bash -c "/home/ctf/tools/bin/manage-tools $*"
|
||||
exit $?
|
Loading…
Reference in a new issue