Last active
January 26, 2016 22:41
-
-
Save ryankurte/b0aa957895d50d8953c0 to your computer and use it in GitHub Desktop.
Docker helper scripts and dockerfiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker container for python apps | |
FROM debian:stable | |
RUN apt-get update && apt-get install -y libc6 libc6-dev \ | |
python-setuptools\ | |
python-pip | |
RUN mkdir -p /usr/src/app | |
WORKDIR /usr/src/app | |
COPY . /usr/src/app | |
RUN python setup.py install | |
CMD [ "python", "/usr/src/app/main.py" ] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convenience makefile for docker projects | |
CONTAINER_NAME=test-container | |
CONTAINER_IMAGE=ryankurte/test_image | |
COMMON_ARGS=--name="${CONTAINER_NAME}" ${CONTAINER_IMAGE} | |
args: | |
echo "Common args: ${COMMON_ARGS}" | |
echo "Image: ${CONTAINER_IMAGE}" | |
echo "Name: ${CONTAINER_NAME}" | |
test: | |
python -m pytest tests/ | |
run: | |
python ./main.py | |
build: | |
docker build --tag ${CONTAINER_IMAGE} . | |
container-test: build | |
docker run -i -t --rm ${CONTAINER_IMAGE} python -m pytest tests/ | |
container-run: build | |
docker run -i -t --rm ${COMMON_ARGS} python ./main.py | |
container-start: build | |
docker run -d --restart=on-failure:10 ${COMMON_ARGS} | |
container-status: | |
docker ps --filter "name=${CONTAINER_NAME}" | |
container-logs: | |
docker logs ${CONTAINER_NAME} | |
container-stop: | |
docker kill ${CONTAINER_NAME} | |
docker rm ${CONTAINER_NAME} | |
container-sh: | |
docker run -i -t --rm ${CONTAINER_NAME} /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment