Compare commits
2 commits
eadd7a5612
...
116e2c1577
| Author | SHA1 | Date | |
|---|---|---|---|
| 116e2c1577 | |||
| cf96371b90 |
6 changed files with 13 additions and 21 deletions
15
Dockerfile
15
Dockerfile
|
|
@ -1,8 +1,9 @@
|
||||||
# stage 1
|
# stage 1
|
||||||
FROM python:3.11-alpine AS backend
|
FROM python:3.11-alpine AS backend
|
||||||
|
|
||||||
ARG USER_UID=1000
|
ARG USER_ID=1000
|
||||||
ARG GROUP_UID=1000
|
ARG GROUP_ID=1000
|
||||||
|
ARG UV_LINK_MODE=copy
|
||||||
|
|
||||||
RUN apk update \
|
RUN apk update \
|
||||||
&& apk add --no-cache \
|
&& apk add --no-cache \
|
||||||
|
|
@ -10,7 +11,7 @@ RUN apk update \
|
||||||
curl \
|
curl \
|
||||||
gettext
|
gettext
|
||||||
|
|
||||||
RUN addgroup -g $USER_UID newsreader && adduser -Du $GROUP_UID -G newsreader newsreader
|
RUN addgroup -g $USER_ID newsreader && adduser -Du $GROUP_ID -G newsreader newsreader
|
||||||
|
|
||||||
RUN mkdir --parents /app/src /app/logs /app/media /app/bin /app/static \
|
RUN mkdir --parents /app/src /app/logs /app/media /app/bin /app/static \
|
||||||
&& chown -R newsreader:newsreader /app
|
&& chown -R newsreader:newsreader /app
|
||||||
|
|
@ -23,7 +24,7 @@ COPY --chown=newsreader:newsreader uv.lock pyproject.toml /app/
|
||||||
|
|
||||||
COPY --from=ghcr.io/astral-sh/uv:python3.11-alpine /usr/local/bin/uv /bin/uv
|
COPY --from=ghcr.io/astral-sh/uv:python3.11-alpine /usr/local/bin/uv /bin/uv
|
||||||
|
|
||||||
RUN --mount=type=cache,target=$HOME/.cache/uv \
|
RUN --mount=type=cache,uid=$USER_ID,gid=$GROUP_ID,target=/home/newsreader/.cache/uv \
|
||||||
uv sync --frozen --no-default-groups --no-install-project
|
uv sync --frozen --no-default-groups --no-install-project
|
||||||
|
|
||||||
COPY --chown=newsreader:newsreader ./bin/docker-entrypoint.sh /app/bin/docker-entrypoint.sh
|
COPY --chown=newsreader:newsreader ./bin/docker-entrypoint.sh /app/bin/docker-entrypoint.sh
|
||||||
|
|
@ -45,7 +46,7 @@ USER node
|
||||||
|
|
||||||
COPY --chown=node:node ./package*.json ./webpack.*.js ./babel.config.js /app/
|
COPY --chown=node:node ./package*.json ./webpack.*.js ./babel.config.js /app/
|
||||||
|
|
||||||
RUN --mount=type=cache,target=$HOME/.npm \
|
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
|
||||||
npm ci
|
npm ci
|
||||||
|
|
||||||
COPY --chown=node:node ./src /app/src
|
COPY --chown=node:node ./src /app/src
|
||||||
|
|
@ -60,7 +61,7 @@ FROM backend AS production
|
||||||
COPY --from=frontend-build --chown=newsreader:newsreader \
|
COPY --from=frontend-build --chown=newsreader:newsreader \
|
||||||
/app/src/newsreader/static /app/src/newsreader/static
|
/app/src/newsreader/static /app/src/newsreader/static
|
||||||
|
|
||||||
RUN --mount=type=cache,target=$HOME/.cache/uv \
|
RUN --mount=type=cache,uid=$USER_ID,gid=$GROUP_ID,target=/home/newsreader/.cache/uv \
|
||||||
uv sync --frozen --only-group production --extra sentry
|
uv sync --frozen --only-group production --extra sentry
|
||||||
|
|
||||||
COPY --chown=newsreader:newsreader ./src /app/src
|
COPY --chown=newsreader:newsreader ./src /app/src
|
||||||
|
|
@ -75,5 +76,5 @@ RUN uv run --no-sync -- src/manage.py collectstatic --noinput
|
||||||
# (optional) stage 4
|
# (optional) stage 4
|
||||||
FROM backend AS development
|
FROM backend AS development
|
||||||
|
|
||||||
RUN --mount=type=cache,target=$HOME/.cache/uv \
|
RUN --mount=type=cache,uid=$USER_ID,gid=$GROUP_ID,target=/home/newsreader/.cache/uv \
|
||||||
uv sync --frozen --group development
|
uv sync --frozen --group development
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
import os
|
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from newsreader.conf.utils import get_env, get_root_dir
|
from newsreader.conf.utils import get_env, get_root_dir
|
||||||
|
|
@ -186,9 +182,7 @@ USE_TZ = True
|
||||||
|
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
STATIC_ROOT = BASE_DIR / "static"
|
STATIC_ROOT = BASE_DIR / "static"
|
||||||
STATICFILES_DIRS = (
|
STATICFILES_DIRS = (DJANGO_PROJECT_DIR / "static",)
|
||||||
DJANGO_PROJECT_DIR / "static",
|
|
||||||
)
|
|
||||||
|
|
||||||
STATICFILES_FINDERS = [
|
STATICFILES_FINDERS = [
|
||||||
"django.contrib.staticfiles.finders.FileSystemFinder",
|
"django.contrib.staticfiles.finders.FileSystemFinder",
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
INSTALLED_APPS += ["debug_toolbar", "django_extensions"] # noqa: F405
|
INSTALLED_APPS += ["debug_toolbar", "django_extensions"] # noqa: F405
|
||||||
|
|
||||||
|
|
||||||
TEMPLATES[0]["OPTIONS"]["context_processors"].append(
|
TEMPLATES[0]["OPTIONS"]["context_processors"].append( # noqa: F405
|
||||||
"django.template.context_processors.debug",
|
"django.template.context_processors.debug",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ LOGGING["loggers"].update( # noqa: F405
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
|
|
||||||
TEMPLATES[0]["OPTIONS"]["context_processors"].append(
|
TEMPLATES[0]["OPTIONS"]["context_processors"].append( # noqa: F405
|
||||||
"django.template.context_processors.debug",
|
"django.template.context_processors.debug",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import os
|
|
||||||
|
|
||||||
from newsreader.conf.utils import get_env
|
from newsreader.conf.utils import get_env
|
||||||
|
|
||||||
from .base import * # noqa: F403
|
from .base import * # noqa: F403
|
||||||
|
|
@ -11,8 +9,7 @@ DEBUG = False
|
||||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||||
|
|
||||||
ADMINS = [
|
ADMINS = [
|
||||||
("", email)
|
("", email) for email in get_env("ADMINS", split=",", required=False, default=[])
|
||||||
for email in get_env("ADMINS", split=",", required=False, default=[])
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Project settings
|
# Project settings
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ def get_env(
|
||||||
cast: Type = str,
|
cast: Type = str,
|
||||||
required: bool = True,
|
required: bool = True,
|
||||||
default: Any = None,
|
default: Any = None,
|
||||||
split: str = ""
|
split: str = "",
|
||||||
) -> Any:
|
) -> Any:
|
||||||
if cast is not str and split:
|
if cast is not str and split:
|
||||||
raise TypeError(f"Split is not possible with {cast}")
|
raise TypeError(f"Split is not possible with {cast}")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue