mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-15 17:34:52 +03:00
decontainer setup
This commit is contained in:
parent
c19957604a
commit
2b39ccee35
|
@ -17,6 +17,7 @@
|
|||
"windows": "n",
|
||||
"use_pycharm": "n",
|
||||
"use_docker": "n",
|
||||
"use_vscode_devcontainer": "n",
|
||||
"postgresql_version": [
|
||||
"14",
|
||||
"13",
|
||||
|
|
|
@ -45,6 +45,13 @@ def remove_gplv3_files():
|
|||
os.remove(file_name)
|
||||
|
||||
|
||||
def remove_vscode_devcontainer_files():
|
||||
dir_paths = [".devcontainer", ".history"]
|
||||
for dir_path in dir_paths:
|
||||
if os.path.exists(dir_path):
|
||||
shutil.rmtree(dir_path)
|
||||
|
||||
|
||||
def remove_pycharm_files():
|
||||
idea_dir_path = ".idea"
|
||||
if os.path.exists(idea_dir_path):
|
||||
|
@ -56,11 +63,13 @@ def remove_pycharm_files():
|
|||
|
||||
|
||||
def remove_docker_files():
|
||||
shutil.rmtree("compose")
|
||||
if "{{ cookiecutter.use_vscode_devcontainer }}".lower() == "n":
|
||||
shutil.rmtree("compose")
|
||||
|
||||
file_names = ["local.yml", "production.yml", ".dockerignore"]
|
||||
for file_name in file_names:
|
||||
os.remove(file_name)
|
||||
|
||||
file_names = ["local.yml", "production.yml", ".dockerignore"]
|
||||
for file_name in file_names:
|
||||
os.remove(file_name)
|
||||
if "{{ cookiecutter.use_pycharm }}".lower() == "y":
|
||||
file_names = ["docker_compose_up_django.xml", "docker_compose_up_docs.xml"]
|
||||
for file_name in file_names:
|
||||
|
@ -449,6 +458,9 @@ def main():
|
|||
else:
|
||||
remove_docker_files()
|
||||
|
||||
if "{{ cookiecutter.use_vscode_devcontainer }}".lower() == "n":
|
||||
remove_vscode_devcontainer_files()
|
||||
|
||||
if (
|
||||
"{{ cookiecutter.use_docker }}".lower() == "y"
|
||||
and "{{ cookiecutter.cloud_provider}}" != "AWS"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
#
|
||||
# .bashrc.override.sh
|
||||
#
|
||||
|
||||
# persistent bash history
|
||||
HISTFILE=~/.bash_history
|
||||
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
|
||||
|
||||
# set some django env vars
|
||||
source /entrypoint
|
||||
|
||||
# restore default shell options
|
||||
set +o errexit
|
||||
set +o pipefail
|
||||
set +o nounset
|
|
@ -0,0 +1,72 @@
|
|||
// For format details, see https://containers.dev/implementors/json_reference/
|
||||
{
|
||||
"name": "{{cookiecutter.project_slug}}_dev",
|
||||
"dockerComposeFile": [
|
||||
"../local.yml"
|
||||
],
|
||||
"init": true,
|
||||
"mounts": [
|
||||
{
|
||||
"source": "./.history/bash_history",
|
||||
"target": "/home/vscode/.bash_history",
|
||||
"type": "bind"
|
||||
},
|
||||
{
|
||||
"source": "/tmp",
|
||||
"target": "/tmp",
|
||||
"type": "bind"
|
||||
}
|
||||
],
|
||||
// Tells devcontainer.json supporting services / tools whether they should run
|
||||
// /bin/sh -c "while sleep 1000; do :; done" when starting the container instead of the container’s default command
|
||||
"overrideCommand": true,
|
||||
"service": "django",
|
||||
// "remoteEnv": {"PATH": "/home/vscode/.local/bin:${containerEnv:PATH}"},
|
||||
"remoteUser": "vscode",
|
||||
"workspaceFolder": "/app",
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {
|
||||
"editor.formatOnSave": true,
|
||||
"python.analysis.autoImportCompletions": true,
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
||||
// "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
|
||||
"python.formatting.blackPath": "/usr/local/bin/black",
|
||||
"python.formatting.provider": "black",
|
||||
// "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
|
||||
// "python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.flake8Enabled": true,
|
||||
"python.linting.flake8Path": "/usr/local/bin/flake8",
|
||||
"python.linting.mypyEnabled": true,
|
||||
"python.linting.mypyPath": "/usr/local/bin/mypy",
|
||||
"python.linting.pycodestylePath": "/usr/local/bin/pycodestyle",
|
||||
// "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
||||
"python.linting.pylintEnabled": true,
|
||||
"python.linting.pylintPath": "/usr/local/bin/pylint",
|
||||
"python.languageServer": "Pylance"
|
||||
},
|
||||
// https://code.visualstudio.com/docs/remote/devcontainerjson-reference#_vs-code-specific-properties
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
"extensions": [
|
||||
"davidanson.vscode-markdownlint",
|
||||
"mrmlnc.vscode-duplicate",
|
||||
"visualstudioexptteam.vscodeintellicode",
|
||||
"visualstudioexptteam.intellicode-api-usage-examples",
|
||||
// python
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
// django
|
||||
"batisteo.vscode-django"
|
||||
]
|
||||
}
|
||||
},
|
||||
// Uncomment the next line if you want start specific services in your Docker Compose config.
|
||||
// "runServices": [],
|
||||
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
|
||||
// "shutdownAction": "none",
|
||||
// Uncomment the next line to run commands after the container is created.
|
||||
"postCreateCommand": "cat .devcontainer/bashrc.override.sh >> ~/.bashrc"
|
||||
}
|
1
{{cookiecutter.project_slug}}/.prettierignore
Normal file
1
{{cookiecutter.project_slug}}/.prettierignore
Normal file
|
@ -0,0 +1 @@
|
|||
*.html
|
|
@ -35,6 +35,18 @@ ENV BUILD_ENV ${BUILD_ENVIRONMENT}
|
|||
|
||||
WORKDIR ${APP_HOME}
|
||||
|
||||
{% if cookiecutter.vscode_devcontainer == "y" %}
|
||||
# VS Code devcontainer dependencies and utils
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
sudo git bash-completion nano
|
||||
|
||||
# Create vscode user and add it to sudoers
|
||||
RUN groupadd --gid 1000 vscode \
|
||||
&& useradd --uid 1000 --gid vscode --shell /bin/bash --create-home vscode \
|
||||
&& echo vscode ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/vscode \
|
||||
&& chmod 0440 /etc/sudoers.d/vscode
|
||||
{% endif %}
|
||||
|
||||
# Install required system dependencies
|
||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||
# psycopg2 dependencies
|
||||
|
@ -51,7 +63,7 @@ COPY --from=python-build-stage /usr/src/app/wheels /wheels/
|
|||
|
||||
# use wheels to install python dependencies
|
||||
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
|
||||
&& rm -rf /wheels/
|
||||
&& rm -rf /wheels/
|
||||
|
||||
COPY ./compose/production/django/entrypoint /entrypoint
|
||||
RUN sed -i 's/\r$//g' /entrypoint
|
||||
|
|
Loading…
Reference in New Issue
Block a user