From 327f8d8cd0bb2081d075b4deb5546cb01dbb331b Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Thu, 24 Feb 2022 21:11:58 +0100 Subject: [PATCH] Setup for M1 mac & cleanup --- docker-compose-build.yaml | 12 +++++++ docker-compose.yml => docker-compose.yaml | 12 +------ docker/nginx-dev.conf | 41 ----------------------- tasks.py | 10 ++++-- 4 files changed, 21 insertions(+), 54 deletions(-) create mode 100644 docker-compose-build.yaml rename docker-compose.yml => docker-compose.yaml (56%) delete mode 100644 docker/nginx-dev.conf diff --git a/docker-compose-build.yaml b/docker-compose-build.yaml new file mode 100644 index 0000000..f82b83b --- /dev/null +++ b/docker-compose-build.yaml @@ -0,0 +1,12 @@ +version: '2.4' +services: + django: + extends: + file: docker-compose.yaml + service: django + image: crocmagnon/blog:latest + platform: linux/amd64 + +volumes: + staticfiles: {} + media: {} diff --git a/docker-compose.yml b/docker-compose.yaml similarity index 56% rename from docker-compose.yml rename to docker-compose.yaml index 55fd6d7..35742ca 100644 --- a/docker-compose.yml +++ b/docker-compose.yaml @@ -1,7 +1,7 @@ version: '2.4' services: django: - image: crocmagnon/blog:latest + image: crocmagnon/blog:dev build: context: . args: @@ -15,16 +15,6 @@ services: restart: on-failure init: true tty: true - depends_on: - - nginx - nginx: - image: nginx:1.19.2 - ports: - - 8000:80 - volumes: - - staticfiles:/app/static - - media:/app/media - - ./docker/nginx-dev.conf:/etc/nginx/conf.d/default.conf volumes: staticfiles: {} diff --git a/docker/nginx-dev.conf b/docker/nginx-dev.conf deleted file mode 100644 index c34b9ed..0000000 --- a/docker/nginx-dev.conf +++ /dev/null @@ -1,41 +0,0 @@ -server { - server_name localhost:8000; - - client_max_body_size 10M; - - gzip on; - gzip_types - application/javascript - application/x-javascript - application/json - application/rss+xml - application/xml - application/vnd.ms-fontobject - application/font-sfnt - image/svg+xml - image/x-icon - text/xml - text/javascript - text/css - text/plain; - gzip_min_length 256; - gzip_comp_level 5; - gzip_http_version 1.1; - gzip_vary on; - - location /media/ { - alias /app/media/; - expires 30d; - } - - location / { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_pass http://django:8000; - proxy_redirect off; - } - - listen [::]:80; - listen 80; -} diff --git a/tasks.py b/tasks.py index 63f937b..b9b59cd 100644 --- a/tasks.py +++ b/tasks.py @@ -16,6 +16,8 @@ from invoke import Context, task BASE_DIR = Path(__file__).parent.resolve(strict=True) SRC_DIR = BASE_DIR / "src" +COMPOSE_BUILD_FILE = BASE_DIR / "docker-compose-build.yaml" +COMPOSE_BUILD_ENV = {"COMPOSE_FILE": COMPOSE_BUILD_FILE} @task @@ -55,13 +57,17 @@ def check(ctx: Context) -> None: @task def build(ctx: Context) -> None: with ctx.cd(BASE_DIR): - ctx.run("docker-compose build django", pty=True, echo=True) + ctx.run( + "docker-compose build django", pty=True, echo=True, env=COMPOSE_BUILD_ENV + ) @task def publish(ctx: Context) -> None: with ctx.cd(BASE_DIR): - ctx.run("docker-compose push django", pty=True, echo=True) + ctx.run( + "docker-compose push django", pty=True, echo=True, env=COMPOSE_BUILD_ENV + ) @task