diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3edb0b5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,34 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/engine/reference/builder/#dockerignore-file + +**/.DS_Store +**/__pycache__ +**/.venv +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/bin +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/obj +**/secrets.dev.yaml +**/values.dev.yaml +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile index e7a0b67..3fb27d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,50 @@ # syntax=docker/dockerfile:1 -FROM python:3.9-slim-buster + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +ARG PYTHON_VERSION=3.10.4 +FROM python:${PYTHON_VERSION}-slim as base + +# Prevents Python from writing pyc files. +ENV PYTHONDONTWRITEBYTECODE=1 + +# Keeps Python from buffering stdout and stderr to avoid situations where +# the application crashes without emitting any logs due to buffering. +ENV PYTHONUNBUFFERED=1 WORKDIR /app -COPY requirements.txt requirements.txt -RUN pip3 install -r requirements.txt +# Create a non-privileged user that the app will run under. +# See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user +ARG UID=10001 +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid "${UID}" \ + appuser + +# Download dependencies as a separate step to take advantage of Docker's caching. +# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds. +# Leverage a bind mount to requirements.txt to avoid having to copy them into +# into this layer. +ADD requirements.txt /app +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=bind,source=requirements.txt,target=requirements.txt \ + python -m pip install -r requirements.txt + +# Switch to the non-privileged user to run the application. +USER appuser +# Copy the source code into the container. COPY . . +# Expose the port that the application listens on. EXPOSE 8000 -CMD [ "gunicorn", "containers_python_django.wsgi:application", "--bind", "0.0.0.0:8000" ] +# Run the application. +CMD gunicorn 'containers_python_django.wsgi' --bind=0.0.0.0:8000 diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..4ea1237 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,49 @@ +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Docker compose reference guide at +# https://docs.docker.com/compose/compose-file/ + +# Here the instructions define your application as a service called "server". +# This service is built from the Dockerfile in the current directory. +# You can add other services your application may depend on here, such as a +# database or a cache. For examples, see the Awesome Compose repository: +# https://github.com/docker/awesome-compose +services: + server: + build: + context: . + ports: + - 8000:8000 + +# The commented out section below is an example of how to define a PostgreSQL +# database that your application can use. `depends_on` tells Docker Compose to +# start the database before your application. The `db-data` volume persists the +# database data between container restarts. The `db-password` secret is used +# to set the database password. You must create `db/password.txt` and add +# a password of your choosing to it before running `docker compose up`. +# depends_on: +# db: +# condition: service_healthy +# db: +# image: postgres +# restart: always +# user: postgres +# secrets: +# - db-password +# volumes: +# - db-data:/var/lib/postgresql/data +# environment: +# - POSTGRES_DB=example +# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password +# expose: +# - 5432 +# healthcheck: +# test: [ "CMD", "pg_isready" ] +# interval: 10s +# timeout: 5s +# retries: 5 +# volumes: +# db-data: +# secrets: +# db-password: +# file: db/password.txt + diff --git a/containers_python_django/__pycache__/__init__.cpython-310.pyc b/containers_python_django/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..78010b9 Binary files /dev/null and b/containers_python_django/__pycache__/__init__.cpython-310.pyc differ diff --git a/containers_python_django/__pycache__/settings.cpython-310.pyc b/containers_python_django/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..1b24c58 Binary files /dev/null and b/containers_python_django/__pycache__/settings.cpython-310.pyc differ diff --git a/containers_python_django/__pycache__/urls.cpython-310.pyc b/containers_python_django/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..87a9de5 Binary files /dev/null and b/containers_python_django/__pycache__/urls.cpython-310.pyc differ diff --git a/containers_python_django/__pycache__/wsgi.cpython-310.pyc b/containers_python_django/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..4815148 Binary files /dev/null and b/containers_python_django/__pycache__/wsgi.cpython-310.pyc differ diff --git a/containers_python_django/settings.py b/containers_python_django/settings.py index 7857ca5..5b98800 100644 --- a/containers_python_django/settings.py +++ b/containers_python_django/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['containersdjango-alysson.b4a.run','node26a.containers.back4app.com' ] +ALLOWED_HOSTS = ['containersdjango-alysson.b4a.run','dockersample-vkaizn.b4a.run','*' ] diff --git a/main/__pycache__/__init__.cpython-310.pyc b/main/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..92669c0 Binary files /dev/null and b/main/__pycache__/__init__.cpython-310.pyc differ diff --git a/main/__pycache__/admin.cpython-310.pyc b/main/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..f66750a Binary files /dev/null and b/main/__pycache__/admin.cpython-310.pyc differ diff --git a/main/__pycache__/apps.cpython-310.pyc b/main/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..5241cf3 Binary files /dev/null and b/main/__pycache__/apps.cpython-310.pyc differ diff --git a/main/__pycache__/models.cpython-310.pyc b/main/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..20e3d8f Binary files /dev/null and b/main/__pycache__/models.cpython-310.pyc differ diff --git a/main/__pycache__/views.cpython-310.pyc b/main/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..82c23ae Binary files /dev/null and b/main/__pycache__/views.cpython-310.pyc differ diff --git a/main/migrations/__pycache__/__init__.cpython-310.pyc b/main/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..a20d91c Binary files /dev/null and b/main/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/main/static/Untitled.png b/main/static/Untitled.png new file mode 100644 index 0000000..d026120 Binary files /dev/null and b/main/static/Untitled.png differ diff --git a/main/templates/home.html b/main/templates/home.html index 1454a1d..1c7f7bc 100644 --- a/main/templates/home.html +++ b/main/templates/home.html @@ -1,7 +1,8 @@ +{% load static %}
-