Skip to content

Instantly share code, notes, and snippets.

@dnozay
Created April 8, 2019 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnozay/b43ee64db4dacd0715f7b7d1a5b469c1 to your computer and use it in GitHub Desktop.
Save dnozay/b43ee64db4dacd0715f7b7d1a5b469c1 to your computer and use it in GitHub Desktop.
random stuff with docker-compose, mysql, python, tox and pip wheels
export DOCKER_BUILDKIT=1
docker build --tag test-tox-image --secret id=pip,src=/Users/dnozay/.pip/pip.conf -f Dockerfile-tox .
docker run -it --rm mysql:5.7 --verbose --help
docker logs --follow db_1
docker-compose up
docker-compose run --rm app bash
docker-compose rm -v
docker images --filter "dangling=true" -q | xargs docker rmi
pytest -n 0  --disable-warnings
version: '3.7'
services:
db:
image: mysql:5.7
volumes:
- ./var/db:/var/lib/mysql
restart: always
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: some-root-password
MYSQL_DATABASE: some-db-name
MYSQL_USER: app
MYSQL_PASSWORD: some-dummy-password
app:
image: test-tox-image
command: tox
volumes:
- .:/src:ro
links:
- db
ports:
- "8080:8080"
tty: true
stdin_open: true
restart: always
secrets:
- pip
secrets:
pip:
file: ~/.pip/pip.conf
#!/usr/bin/env bash
set -o errexit
# copy stuff from /src (mount bind, ro) into rw filesystem
# where things like .tox, .eggs directory can get written.
find /src -mindepth 1 -maxdepth 1 \
\( -type d -name ".*" -prune \) \
\( -type d -name "var" -prune \) \
-o -exec cp -r --target-directory=/app -- {} +
pip install .
tox --notest
alias pytest="~/.virtualenvs/myapp/bin/pytest --maxfail=1"
# If the first argument was not "tox", run whichever command was given.
exec "$@"
# syntax=docker/dockerfile:experimental
FROM python:3.7
COPY requirements.txt .
COPY requirements-tox.txt .
RUN --mount=type=secret,id=pip,dst=/root/.pip/pip.conf \
pip download --destination-directory /root/.pip/cache \
-r requirements.txt \
-r requirements-tox.txt \
tox wheel
ENV PIP_DOWNLOAD_CACHE /root/.pip/cache
RUN pip wheel \
--wheel-dir /root/.pip/wheels \
--no-index --find-links /root/.pip/cache \
-r requirements.txt \
-r requirements-tox.txt \
tox wheel
RUN pip install \
--no-index --find-links /root/.pip/wheels \
-r requirements.txt tox
The MIT License (MIT)
Copyright (c) 2019 Damien Nozay
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
[testenv]
install_command =
pip install --no-index --find-links {homedir}/.pip/wheels -U {packages}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment