mirror of
https://github.com/decompme/decomp.me.git
synced 2026-05-18 05:49:06 -05:00
Adding docker-compose.yaml
This commit is contained in:
@@ -4,3 +4,4 @@ node_modules
|
||||
build
|
||||
.snowpack
|
||||
backend/local_files/
|
||||
postgres/
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Docker
|
||||
|
||||
There is a `docker-compose.yaml` file to help you spin up an instance quickly.
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
### Docker
|
||||
|
||||
You will need [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/). Follow the instructions for your distro.
|
||||
|
||||
### Directories
|
||||
|
||||
You will need to create a directory for the `postgres` data:
|
||||
|
||||
```sh
|
||||
mkdir -p postgres
|
||||
```
|
||||
|
||||
**Note:** This directory will get owned by 'postgres' user when postgres first starts up!
|
||||
|
||||
## Quickstart
|
||||
|
||||
```sh
|
||||
docker-compose up -d && docker-compose logs -f
|
||||
```
|
||||
|
||||
You can CTRL+C to stop tailing logs. If you want to stop the processes then running `docker-compose down` will shut everything down.
|
||||
|
||||
**Note:** The first time you bring up the containers can take a minute or so - Docker has to pull/build images, grab node dependencies, apply database migrations etc. Subsequent runs will be significantly faster to spin up.
|
||||
|
||||
### Re-building Images
|
||||
|
||||
If the Docker images become stale (e.g. updates are made to `requirements.txt`), then you can run the following to build the images before they are spin up:
|
||||
|
||||
```sh
|
||||
docker-compose up -d --build
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
FROM python:3.9 AS build
|
||||
|
||||
RUN apt-get update && apt-get install -y netcat binutils-mips-linux-gnu
|
||||
|
||||
COPY requirements.txt /backend/requirements.txt
|
||||
|
||||
RUN python3 -m pip install -r /backend/requirements.txt --no-cache-dir
|
||||
|
||||
WORKDIR /backend
|
||||
|
||||
ENTRYPOINT ["/backend/docker_entrypoint.sh"]
|
||||
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import environ
|
||||
@@ -14,8 +16,10 @@ env = environ.Env(
|
||||
SECURE_HSTS_PRELOAD=(bool, False),
|
||||
)
|
||||
|
||||
with open(BASE_DIR / ".." / ".env") as f:
|
||||
environ.Env.read_env(f)
|
||||
env_file = BASE_DIR / ".." / ".env"
|
||||
if os.path.isfile(env_file):
|
||||
with open() as f:
|
||||
environ.Env.read_env(f)
|
||||
|
||||
SECRET_KEY = env('SECRET_KEY')
|
||||
DEBUG = env('DEBUG')
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
DB_HOST=${DATABASE_HOST:-postgres}
|
||||
DB_PORT=${DATABASE_PORT:-5432}
|
||||
|
||||
BE_HOST=${BACKEND_HOST:-0.0.0.0}
|
||||
BE_PORT=${BACKEND_PORT:-8000}
|
||||
|
||||
until nc -z ${DB_HOST} ${DB_PORT} > /dev/null; do
|
||||
echo "Waiting for database to become available on ${DB_HOST}:${DB_PORT}..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
python /backend/manage.py migrate
|
||||
|
||||
python /backend/manage.py loaddata /backend/db.json
|
||||
|
||||
python /backend/manage.py runserver ${BE_HOST}:${BE_PORT}
|
||||
@@ -0,0 +1,28 @@
|
||||
version: '2'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13
|
||||
environment:
|
||||
POSTGRES_USER: decompme
|
||||
POSTGRES_PASSWORD: decompme
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./postgres:/var/lib/postgresql/data
|
||||
backend:
|
||||
build: backend
|
||||
environment:
|
||||
DATABASE_URL: psql://decompme:decompme@postgres:5432/decompme
|
||||
SECRET_KEY: "django-insecure-nm#!8%z$$hc0wwi#m_*l9l)=m*6gs4&o_^-e5b5vj*k05&yaqc1"
|
||||
DEBUG: "on"
|
||||
ALLOWED_HOSTS: "localhost,127.0.0.1"
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- ./backend:/backend
|
||||
frontend:
|
||||
build: frontend
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./frontend:/frontend
|
||||
@@ -0,0 +1,5 @@
|
||||
FROM node:16 AS build
|
||||
|
||||
WORKDIR /frontend
|
||||
|
||||
ENTRYPOINT ["/frontend/docker_entrypoint.sh"]
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
yarn install --frozen-lockfile
|
||||
|
||||
yarn start
|
||||
Reference in New Issue
Block a user