Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
minor reorganization, docker-compose for SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
krishchow committed Jan 4, 2021
1 parent 93b7a7f commit b5a134e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
build :
build:
ifeq ($(env), local)
cd frontend && npm install
else
docker-compose up --build
endif

run :
run:
ifeq ($(env), local)
cd frontend && npm run dev
else
docker-compose up
endif

down :
down:
docker-compose down --remove-orphans

prettier :
prettier:
cd frontend && npx prettier --write .
cd frontend && npm run lint -- --fix
cd frontend && npm run lint -- --fix
13 changes: 11 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@ FROM golang:buster

RUN apt-get update
RUN apt-get install curl
WORKDIR /app

COPY . .
ENV PGUSER=postgres;
ENV PGHOST=postgres;
ENV PGPASSWORD=password;
ENV PGDATABASE=postgres;

WORKDIR /app

RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.33.0
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin

COPY go.mod .
COPY go.sum .

RUN go mod download
RUN go mod vendor

COPY . .

ENV PORT=3001

CMD [ "air" ]
7 changes: 0 additions & 7 deletions backend/storage/README.md

This file was deleted.

14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
version: "3.8"
services:
postgres:
build:
context: ./storage
dockerfile: Dockerfile.db
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRES_DB: postgres
frontend:
stdin_open: true
build:
Expand All @@ -24,4 +34,8 @@ services:
- PORT=3001
volumes:
- ./backend:/app
links:
- postgres
depends_on:
- postgres

5 changes: 5 additions & 0 deletions storage/Dockerfile.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM postgres:13.1
RUN apt-get update && apt-get install -y dos2unix
COPY sql/ /docker-entrypoint-initdb.d
RUN chmod +x /docker-entrypoint-initdb.d/build.sh
RUN find ./docker-entrypoint-initdb.d -type f -print0 | xargs -0 -n 1 -P 4 dos2unix
13 changes: 13 additions & 0 deletions storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Dialog Storage

## SQL

The SQL scripts can be found under [sql](sql/). The custom Dockerfile builds the image, this should only be used for development purposes.

## Notes

All storage related files should go here, this includes but is not limited to:
- Schema
- Database configuration files/scripts
- Object storage
- Caching
9 changes: 9 additions & 0 deletions storage/sql/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd $(dirname $0)

PGUSER=postgres
PGHOST=localhost
PGPASSWORD=postgres
PGDATABASE=postgres
PGPORT=5432

initilize=$(psql -f scripts/discussion-board.sql)

0 comments on commit b5a134e

Please sign in to comment.