Skip to content

Commit

Permalink
deployment files
Browse files Browse the repository at this point in the history
  • Loading branch information
lecafard committed Sep 25, 2020
1 parent f7fee24 commit 1e5dbff
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__/
venv/
.env
3 changes: 3 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
*.pyc
venv/
11 changes: 11 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8-buster

RUN apt-get update &&\
apt-get install -y postgresql-client &&\
rm -rf /var/lib/apt/lists/
RUN pip install gunicorn
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt

CMD ["gunicorn", "-b", "0.0.0.0:8000", "app:app"]
16 changes: 16 additions & 0 deletions backend/wait-for-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# wait-for-postgres.sh

set -e

host="$1"
shift
cmd="$@"

until PGPASSWORD=$POSTGRES_PASSWORD psql -h "$host" -U "postgres" -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done

>&2 echo "Postgres is up - executing command"
exec $cmd
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "2.2"

services:
backend:
image: lecafard/when3meet_backend
build: ./backend
restart: unless-stopped
ports:
- "8000:8000"
depends_on:
- postgres
environment:
- POSTGRES_CONNECTION=postgres://when3meet:${POSTGRES_PASSWORD}@postgres/when3meet
frontend:
image: lecafard/when3meet_frontend
build: ./frontend
restart: unless-stopped
ports:
- "80:80"
depends_on:
- backend
postgres:
image: postgres:13-alpine
restart: unless-stopped
environment:
- POSTGRES_USER=when3meet
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=when3meet
volumes:
- db:/var/lib/postgresql/data
volumes:
db:
2 changes: 2 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
11 changes: 11 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:14 AS builder
WORKDIR /app
COPY package.json /app/
RUN yarn install
COPY ./ /app/
RUN yarn build

FROM nginx:1.19-alpine
COPY --from=builder /app/build/ /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

18 changes: 18 additions & 0 deletions frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://backend:8000;
}
error_page 404 /index.html;

}

0 comments on commit 1e5dbff

Please sign in to comment.