-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from nyu-devops/docker-in-docker
Docker in docker
- Loading branch information
Showing
24 changed files
with
1,205 additions
and
229 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# DevOps Workshop 2021 Image for Python3 and Docker | ||
FROM python:3.9-slim | ||
|
||
ARG INSTALL_ZSH="true" | ||
ARG UPGRADE_PACKAGES="false" | ||
ARG ENABLE_NONROOT_DOCKER="true" | ||
ARG USE_MOBY="true" | ||
ARG DOCKER_VERSION="latest" | ||
|
||
# Enable new "BUILDKIT" mode for Docker CLI | ||
ENV DOCKER_BUILDKIT=1 | ||
|
||
# Create a user for development | ||
ARG USERNAME=vscode | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
COPY .devcontainer/library-scripts/*.sh /tmp/library-scripts/ | ||
RUN apt-get update \ | ||
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \ | ||
# Use Docker script from script library to set things up | ||
&& /bin/bash /tmp/library-scripts/docker-in-docker-debian.sh "${ENABLE_NONROOT_DOCKER}" "${USERNAME}" "${USE_MOBY}" "${DOCKER_VERSION}" \ | ||
# Clean up | ||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/ | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
# && apt-get -y install --no-install-recommends <your-package-list-here> | ||
|
||
# Set up the Kubernetes tools | ||
RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$(dpkg --print-architecture)/kubectl" \ | ||
&& install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \ | ||
&& echo "alias kc='/usr/local/bin/kubectl'" >> /home/$USERNAME/.bash_aliases \ | ||
&& chown $USERNAME:$USERNAME /home/$USERNAME/.bash_aliases \ | ||
&& curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash \ | ||
&& curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | ||
|
||
# Update Python tools | ||
RUN pip3 install -U pip wheel setuptools | ||
|
||
# Set up the development environment | ||
WORKDIR /app | ||
VOLUME [ "/var/lib/docker" ] | ||
|
||
# Become a regular user | ||
USER $USERNAME | ||
|
||
# Setting the ENTRYPOINT to docker-init.sh will start up the Docker Engine | ||
# inside the container "overrideCommand": false is set in devcontainer.json. | ||
# The script will also execute CMD if you need to alter startup behaviors. | ||
ENTRYPOINT [ "/usr/local/share/docker-init.sh" ] | ||
CMD [ "sleep", "infinity" ] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "Python Docker", | ||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "app", | ||
"workspaceFolder": "/app", | ||
"remoteUser": "vscode", | ||
"overrideCommand": false, | ||
"settings": {}, | ||
"extensions": [ | ||
"VisualVisualStudioExptTeam.vscodeintellicodeStudio", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"ms-azuretools.vscode-docker", | ||
"wholroyd.jinja", | ||
"cstrap.flask-snippets", | ||
"yzhang.markdown-all-in-one", | ||
"DavidAnson.vscode-markdownlint", | ||
"bierner.github-markdown-preview", | ||
"donjayamanne.githistory", | ||
"redhat.vscode-yaml", | ||
"inercia.vscode-k3d" | ||
], | ||
"postCreateCommand": "pip install -U pip wheel && pip install -r requirements.txt", | ||
"features": { | ||
"docker-in-docker": { | ||
"version": "latest", | ||
"moby": true | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
version: "3" | ||
|
||
services: | ||
app: | ||
build: | ||
context: .. | ||
dockerfile: .devcontainer/Dockerfile | ||
hostname: devops | ||
init: true | ||
privileged: true | ||
# ports: | ||
# - 5000:5000 | ||
volumes: | ||
- ..:/app | ||
- ~/.gitconfig:/home/vscode/.gitconfig | ||
- ~/.ssh/:/home/vscode/.ssh/ | ||
- dind-var-lib-docker:/var/lib/docker | ||
command: sleep infinity | ||
environment: | ||
FLASK_APP: service:app | ||
PORT: 5000 | ||
DATABASE_URI: "redis://redis:6379/0" | ||
networks: | ||
- dev | ||
depends_on: | ||
- redis | ||
|
||
redis: | ||
image: redis:6-alpine | ||
hostname: redis | ||
ports: | ||
- "6379:6379" | ||
volumes: | ||
- redis:/data | ||
networks: | ||
- dev | ||
|
||
volumes: | ||
redis: | ||
dind-var-lib-docker: | ||
|
||
networks: | ||
dev: |
Oops, something went wrong.