-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dockerfile, devcontainer, and codespaces support
- Loading branch information
Michael Panchenko
committed
Jun 6, 2024
1 parent
f6f79ca
commit 83b70ff
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
{{cookiecutter.project_name}}/.devcontainer/devcontainer.json
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,16 @@ | ||
{ | ||
"name": "{{cookiecutter.project_name}} Project", | ||
"dockerFile": "../Dockerfile", | ||
"workspaceFolder": "/workspaces/{{cookiecutter.project_name}}", | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash", | ||
"python.pythonPath": "/usr/local/bin/python", | ||
}, | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-toolsai.jupyter", | ||
"ms-python.vscode-pylance" | ||
], | ||
"forwardPorts": [], | ||
"remoteUser": "root", | ||
} |
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,9 @@ | ||
data | ||
logs | ||
log | ||
test/log | ||
docs/jupyter_execute | ||
docs/.jupyter_cache | ||
docs/_build | ||
coverage.xml | ||
docker_build_and_run.sh |
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,36 @@ | ||
# Use the official Python image for the base image. | ||
FROM python:{{cookiecutter.python_version}}-slim | ||
|
||
# Set environment variables to make Python print directly to the terminal and avoid .pyc files. | ||
ENV PYTHONUNBUFFERED 1 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
|
||
# Install system dependencies required for pipx and Poetry. | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
curl \ | ||
build-essential \ | ||
git \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install pipx. | ||
RUN python3 -m pip install --no-cache-dir pipx \ | ||
&& pipx ensurepath | ||
|
||
# Add poetry to the path | ||
ENV PATH="${PATH}:/root/.local/bin" | ||
|
||
# Install the latest version of Poetry using pipx. | ||
RUN pipx install poetry | ||
|
||
# Set the working directory. IMPORTANT: can't be changed as needs to be in sync to the dir where the project is cloned | ||
# to in the codespace | ||
WORKDIR /workspaces/{{cookiecutter.project_name}} | ||
|
||
# Copy the pyproject.toml and poetry.lock files (if available) into the image. | ||
COPY pyproject.toml poetry.lock* /workspaces/{{cookiecutter.project_name}}/ | ||
|
||
RUN poetry install --with dev | ||
|
||
# Entrypoint should be a shell in the workdir with poetry shell activated | ||
# Before that, the project should be installed with poetry install | ||
ENTRYPOINT ["/bin/bash", "-c", "poetry install --with dev && poetry shell && $0 $@"] |
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
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,5 @@ | ||
#!/usr/bin/bash | ||
|
||
docker build -t {{cookiecutter.project_name}} . | ||
|
||
docker run -it --rm -v "$(pwd)":/workspace {{cookiecutter.project_name}} |