Improve dev setup
Build and Push Lunchtime Images (Kaniko) / build-and-push (push) Has been cancelled
Build and Push Lunchtime Images (Kaniko) / build-and-push (push) Has been cancelled
This commit is contained in:
@@ -65,6 +65,7 @@ jobs:
|
|||||||
/kaniko/executor
|
/kaniko/executor
|
||||||
--context=$GITHUB_WORKSPACE/src/frontend
|
--context=$GITHUB_WORKSPACE/src/frontend
|
||||||
--dockerfile=$GITHUB_WORKSPACE/src/frontend/Containerfile
|
--dockerfile=$GITHUB_WORKSPACE/src/frontend/Containerfile
|
||||||
|
--target=prod
|
||||||
${{ steps.meta.outputs.frontend_dests }}"
|
${{ steps.meta.outputs.frontend_dests }}"
|
||||||
|
|
||||||
- name: Build and Push Backend
|
- name: Build and Push Backend
|
||||||
|
|||||||
@@ -46,3 +46,61 @@ docker compose up -d
|
|||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:8080`.
|
Open `http://localhost:8080`.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
### Quick Start with Docker Compose
|
||||||
|
|
||||||
|
Use the development compose file to run the full stack with hot reload:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd src
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
This will start the backend and frontend, proxied through Nginx at `http://localhost:8080`. Also, a Mailpit instance at `http://localhost:8081` can be used for monitoring outgoing mail.
|
||||||
|
|
||||||
|
### Backend Development
|
||||||
|
|
||||||
|
The backend is a FastAPI application using SQLite and runs on Python 3.12.
|
||||||
|
|
||||||
|
**Dockerfile**: `src/backend/Containerfile` - Production build
|
||||||
|
|
||||||
|
**Development**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd src/backend
|
||||||
|
pip install -r requirements.txt
|
||||||
|
uvicorn app.main:app --reload
|
||||||
|
```
|
||||||
|
|
||||||
|
Changes to `app/` are automatically detected when running with `--reload`.
|
||||||
|
|
||||||
|
### Frontend Development
|
||||||
|
|
||||||
|
The frontend is a React + TypeScript application using Vite.
|
||||||
|
|
||||||
|
**Dockerfile**:
|
||||||
|
|
||||||
|
- `src/frontend/Containerfile`: Multi-target build with `dev` and `prod` stages
|
||||||
|
|
||||||
|
Use the `dev` target for hot reload and the `prod` target for the static production image.
|
||||||
|
|
||||||
|
**Development**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd src/frontend
|
||||||
|
npm install
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `http://localhost:5173` (or the address shown in the terminal).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Contributions are welcome! Please follow these guidelines:
|
||||||
|
|
||||||
|
1. **Choose an existing issue** or create one first to discuss your changes
|
||||||
|
2. **Fork the repository** and create a feature branch
|
||||||
|
3. **Test your changes** in the development environment using `compose.yml`
|
||||||
|
4. **Submit a pull request** linking to the related issue
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
services:
|
|
||||||
nginx:
|
|
||||||
volumes:
|
|
||||||
- ../nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
||||||
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: backend
|
|
||||||
dockerfile: Containerfile
|
|
||||||
volumes:
|
|
||||||
- ../.data:/app/data
|
|
||||||
- ../config.yaml:/app/config.yaml:ro
|
|
||||||
- ./backend/app:/app/app
|
|
||||||
command: uvicorn app.main:app --host 0.0.0.0 --port 5000 --reload
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: frontend
|
|
||||||
dockerfile: Containerfile.dev
|
|
||||||
volumes:
|
|
||||||
- ./frontend/src:/app/src
|
|
||||||
- ./frontend/public:/app/public
|
|
||||||
- ./frontend/index.html:/app/index.html
|
|
||||||
- ./frontend/vite.config.ts:/app/vite.config.ts
|
|
||||||
- ./frontend/tsconfig.json:/app/tsconfig.json
|
|
||||||
- ./frontend/tsconfig.node.json:/app/tsconfig.node.json
|
|
||||||
- /app/node_modules
|
|
||||||
command: npm run dev -- --host 0.0.0.0 --port 8000
|
|
||||||
+34
-43
@@ -1,10 +1,41 @@
|
|||||||
services:
|
services:
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: backend
|
||||||
|
dockerfile: Containerfile
|
||||||
|
volumes:
|
||||||
|
- ../.data:/app/data
|
||||||
|
- ../config.yaml:/app/config.yaml:ro
|
||||||
|
- ./backend/app:/app/app
|
||||||
|
environment:
|
||||||
|
- APP_ENV=production
|
||||||
|
- LOG_LEVEL=info
|
||||||
|
- DB_PATH=/app/data
|
||||||
|
- SMTP_HOST=mailpit
|
||||||
|
- SMTP_PORT=1025
|
||||||
|
restart: unless-stopped
|
||||||
|
command: uvicorn app.main:app --host 0.0.0.0 --port 5000 --reload
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
build:
|
||||||
|
context: frontend
|
||||||
|
dockerfile: Containerfile
|
||||||
|
target: dev
|
||||||
|
volumes:
|
||||||
|
- ./frontend/src:/app/src
|
||||||
|
- ./frontend/public:/app/public
|
||||||
|
- ./frontend/index.html:/app/index.html
|
||||||
|
- ./frontend/vite.config.ts:/app/vite.config.ts
|
||||||
|
- ./frontend/tsconfig.json:/app/tsconfig.json
|
||||||
|
- ./frontend/tsconfig.node.json:/app/tsconfig.node.json
|
||||||
|
- /app/node_modules
|
||||||
|
command: npm run dev -- --host 0.0.0.0 --port 8000
|
||||||
|
|
||||||
mailpit:
|
mailpit:
|
||||||
image: axllent/mailpit:latest
|
image: axllent/mailpit:latest
|
||||||
container_name: lunchtime-mailpit
|
container_name: lunchtime-mailpit
|
||||||
ports:
|
ports:
|
||||||
- "1025:1025"
|
- "8081:8081"
|
||||||
- "8025:8025"
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
networks:
|
||||||
burger-network:
|
burger-network:
|
||||||
@@ -13,7 +44,6 @@ services:
|
|||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
container_name: lunchtime-nginx
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -21,43 +51,4 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
- frontend
|
- frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
networks:
|
|
||||||
- burger-network
|
|
||||||
|
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: backend
|
|
||||||
dockerfile: Containerfile
|
|
||||||
container_name: lunchtime-backend
|
|
||||||
volumes:
|
|
||||||
- ../.data:/app/data
|
|
||||||
- ../config.yaml:/app/config.yaml:ro
|
|
||||||
environment:
|
|
||||||
- APP_ENV=production
|
|
||||||
- LOG_LEVEL=info
|
|
||||||
- DB_PATH=/app/data
|
|
||||||
- SMTP_HOST=mailpit
|
|
||||||
- SMTP_PORT=1025
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
burger-network:
|
|
||||||
aliases:
|
|
||||||
- backend
|
|
||||||
depends_on:
|
|
||||||
- mailpit
|
|
||||||
|
|
||||||
frontend:
|
|
||||||
build:
|
|
||||||
context: frontend
|
|
||||||
dockerfile: Containerfile
|
|
||||||
container_name: lunchtime-frontend
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
burger-network:
|
|
||||||
aliases:
|
|
||||||
- frontend
|
|
||||||
|
|
||||||
networks:
|
|
||||||
burger-network:
|
|
||||||
driver: bridge
|
|
||||||
@@ -1,14 +1,27 @@
|
|||||||
FROM node:20-slim AS build
|
FROM node:20-slim AS base
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
|
|
||||||
|
FROM base AS dev
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
EXPOSE 5173
|
||||||
|
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"]
|
||||||
|
|
||||||
|
|
||||||
|
FROM base AS build
|
||||||
|
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
FROM node:20-slim
|
|
||||||
|
FROM node:20-slim AS prod
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -19,6 +32,6 @@ COPY --from=build /app/dist ./
|
|||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
CMD wget -q -O- http://localhost:8000/index.html || exit 1
|
CMD node -e "require('http').get('http://localhost:8000/index.html', (res) => process.exit(res.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
|
||||||
|
|
||||||
CMD ["http-server", ".", "-p", "8000", "-c-1", "--gzip", "-P", "http://localhost:8000?"]
|
CMD ["http-server", ".", "-p", "8000", "-c-1", "--gzip", "-P", "http://localhost:8000?"]
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
FROM node:20-slim
|
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN npm ci
|
|
||||||
|
|
||||||
COPY . ./
|
|
||||||
|
|
||||||
EXPOSE 5173
|
|
||||||
|
|
||||||
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"]
|
|
||||||
Reference in New Issue
Block a user