diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..08221f2 --- /dev/null +++ b/.env.example @@ -0,0 +1,15 @@ +PHX_HOST=aggiedit.simponic.xyz + +POSTGRES_USER=aggiedit +POSTGRES_PASSWORD=password +POSTGRES_HOSTNAME=db +SECRET_KEY_BASE=secret +PORT=4000 +DATABASE_URL=ecto://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOSTNAME/$POSTGRES_USER + +SMTP_SERVER= +TO_EMAIL= +CONTACT_EMAIL= +EMAIL_PASSWORD= + +USER_UPLOADS= diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dc7615d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' + +services: + prod: + build: ./ + env_file: + - .env + expose: + - 4000 + depends_on: + - 'db' + volumes: + - ${USER_UPLOADS}/uploads:/app/bin/priv/static/uploads + depends_on: + - db + nginx: + build: ./nginx + ports: + - "8081:80" + volumes: + - ${USER_UPLOADS}:/uploads + depends_on: + - prod + db: + image: 'postgres:14' + env_file: + - .env + volumes: + - pgdata:/var/lib/postgresql/data + +volumes: + pgdata: diff --git a/nginx/Dockerfile b/nginx/Dockerfile new file mode 100644 index 0000000..4909c28 --- /dev/null +++ b/nginx/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx:alpine + +COPY ./nginx.conf /etc/nginx/nginx.conf diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..f1704d9 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,36 @@ +worker_processes auto; +pid /run/nginx.pid; +include /etc/nginx/modules-enabled/*.conf; + +events { + worker_connections 1024; +} + +http { + upstream prod { + server prod:4000; + } + + server { + listen 80; + + server_name localhost 127.0.0.1; + + location /uploads { + root /uploads; + } + + location / { + proxy_pass http://prod; + + proxy_http_version 1.1; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect default; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + } +}