shane0 / shane0.github.io

shane null's github pages
https://shane0.github.io/
MIT License
1 stars 0 forks source link

stacks #23

Open shane0 opened 1 year ago

shane0 commented 1 year ago

fastapi sqlite

version: '3'

services:
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    ports:
      - "8000:8000"
    environment:
      - DATABASE_URL=sqlite:///./app.db
    volumes:
      - ./backend:/app
      - ./data:/data
    depends_on:
      - database
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    volumes:
      - ./frontend:/app
  database:
    image: "sqlite:latest"
    volumes:
      - ./data:/data
docker-compose up

This will start all three services and you should be able to access the FastAPI backend at http://localhost:8000 and the React frontend at http://localhost:3000.

shane0 commented 1 year ago

fastapi

FROM python:3.9-slim-buster

WORKDIR /app

COPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txt

COPY . .

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
shane0 commented 1 year ago

react

FROM node:16-alpine

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

CMD ["npm", "start"]