Setup for M1 mac & cleanup

This commit is contained in:
Gabriel Augendre 2022-02-24 21:11:58 +01:00
parent 328aa50acc
commit 327f8d8cd0
4 changed files with 21 additions and 54 deletions

12
docker-compose-build.yaml Normal file
View file

@ -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: {}

View file

@ -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: {}

View file

@ -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;
}

View file

@ -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