Use singular containerfile
Build and Push Lunchtime Images (Kaniko) / build-and-push (push) Successful in 1m7s
Build and Push Lunchtime Images (Kaniko) / build-and-push (push) Successful in 1m7s
This commit is contained in:
@@ -31,17 +31,14 @@ jobs:
|
||||
IMAGE_REPO="$REGISTRY/$IMAGE_NAMESPACE/lunchtime-web"
|
||||
|
||||
# Prepare Kaniko destination arguments
|
||||
FRONTEND_DESTS="--destination $IMAGE_REPO:frontend-$SHORT_SHA"
|
||||
BACKEND_DESTS="--destination $IMAGE_REPO:backend-$SHORT_SHA"
|
||||
DESTS="--destination $IMAGE_REPO:$SHORT_SHA"
|
||||
|
||||
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
|
||||
FRONTEND_DESTS="$FRONTEND_DESTS --destination $IMAGE_REPO:frontend-${GITHUB_REF_NAME}"
|
||||
BACKEND_DESTS="$BACKEND_DESTS --destination $IMAGE_REPO:backend-${GITHUB_REF_NAME}"
|
||||
DESTS="$DESTS --destination $IMAGE_REPO:${GITHUB_REF_NAME}"
|
||||
fi
|
||||
|
||||
if [[ "$GITHUB_REF_NAME" == "main" || "$GITHUB_REF_NAME" == "master" ]]; then
|
||||
FRONTEND_DESTS="$FRONTEND_DESTS --destination $IMAGE_REPO:frontend-latest"
|
||||
BACKEND_DESTS="$BACKEND_DESTS --destination $IMAGE_REPO:backend-latest"
|
||||
DESTS="$DESTS --destination $IMAGE_REPO:latest"
|
||||
fi
|
||||
|
||||
# Create the auth string
|
||||
@@ -49,11 +46,10 @@ jobs:
|
||||
CONFIG_JSON="{\"auths\":{\"$REGISTRY\":{\"auth\":\"$AUTH_B64\"}}}"
|
||||
CONFIG_B64=$(echo -n "$CONFIG_JSON" | base64 -w 0)
|
||||
|
||||
echo "frontend_dests=$FRONTEND_DESTS" >> "$GITHUB_OUTPUT"
|
||||
echo "backend_dests=$BACKEND_DESTS" >> "$GITHUB_OUTPUT"
|
||||
echo "dests=$DESTS" >> "$GITHUB_OUTPUT"
|
||||
echo "config_b64=$CONFIG_B64" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build and Push Frontend
|
||||
- name: Build and Push Lunchtime Web
|
||||
uses: docker://gcr.io/kaniko-project/executor:debug
|
||||
env:
|
||||
DOCKER_CONFIG_B64: ${{ steps.meta.outputs.config_b64 }}
|
||||
@@ -63,20 +59,6 @@ jobs:
|
||||
-c "mkdir -p /kaniko/.docker &&
|
||||
echo $DOCKER_CONFIG_B64 | base64 -d > /kaniko/.docker/config.json &&
|
||||
/kaniko/executor
|
||||
--context=$GITHUB_WORKSPACE/src/frontend
|
||||
--dockerfile=$GITHUB_WORKSPACE/src/frontend/Containerfile
|
||||
${{ steps.meta.outputs.frontend_dests }}"
|
||||
|
||||
- name: Build and Push Backend
|
||||
uses: docker://gcr.io/kaniko-project/executor:debug
|
||||
env:
|
||||
DOCKER_CONFIG_B64: ${{ steps.meta.outputs.config_b64 }}
|
||||
with:
|
||||
entrypoint: /busybox/sh
|
||||
args: >-
|
||||
-c "mkdir -p /kaniko/.docker &&
|
||||
echo $DOCKER_CONFIG_B64 | base64 -d > /kaniko/.docker/config.json &&
|
||||
/kaniko/executor
|
||||
--context=$GITHUB_WORKSPACE/src/backend
|
||||
--dockerfile=$GITHUB_WORKSPACE/src/backend/Containerfile
|
||||
${{ steps.meta.outputs.backend_dests }}"
|
||||
--context=$GITHUB_WORKSPACE/src
|
||||
--dockerfile=$GITHUB_WORKSPACE/src/Containerfile
|
||||
${{ steps.meta.outputs.dests }}"
|
||||
@@ -1,38 +0,0 @@
|
||||
upstream backend {
|
||||
server backend:5000;
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
server frontend:5173;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://backend/api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://frontend/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location /__vite_ping {
|
||||
access_log off;
|
||||
return 200 "pong\n" Content-Type "text/plain";
|
||||
}
|
||||
}
|
||||
Generated
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "lunchtime-web",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
.git
|
||||
.github
|
||||
.gitignore
|
||||
.gitea
|
||||
*.md
|
||||
TODO.md
|
||||
README.md
|
||||
.venv
|
||||
.env
|
||||
.env.local
|
||||
.DS_Store
|
||||
**/node_modules
|
||||
**/dist
|
||||
**/__pycache__
|
||||
**/*.pyc
|
||||
**/*.pyo
|
||||
**/*.db
|
||||
**/*.sqlite3
|
||||
**/.git
|
||||
nginx.conf
|
||||
nginx.dev.conf
|
||||
compose.*
|
||||
@@ -0,0 +1,55 @@
|
||||
# Frontend builder
|
||||
|
||||
FROM node:20-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /frontend
|
||||
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY frontend/src ./src
|
||||
COPY frontend/public ./public
|
||||
COPY frontend/*.json ./
|
||||
COPY frontend/*.html ./
|
||||
RUN npm run build && npm cache clean --force
|
||||
|
||||
# Backend builder
|
||||
|
||||
FROM python:3.12-alpine AS backend-builder
|
||||
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY backend/requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Lunchtime
|
||||
|
||||
FROM python:3.12-alpine
|
||||
|
||||
RUN apk add --no-cache nginx curl && \
|
||||
mkdir -p /etc/nginx/conf.d /app/data && \
|
||||
rm -f /etc/nginx/sites-enabled/default && \
|
||||
chmod 755 /app/data
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=frontend-builder /frontend/dist /usr/share/nginx/html
|
||||
|
||||
COPY --from=backend-builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
||||
COPY --from=backend-builder /usr/local/bin /usr/local/bin
|
||||
|
||||
COPY backend/requirements.txt ./
|
||||
COPY backend/app ./app
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:8080/api/config || exit 1
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -1,22 +0,0 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt ./requirements.txt
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY app ./app
|
||||
|
||||
RUN mkdir -p /app/data && chmod 755 /app/data && \
|
||||
chmod +x /app/entrypoint.sh 2>/dev/null || true
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD curl -f http://localhost:5000/api/config || exit 1
|
||||
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "5000"]
|
||||
@@ -1,28 +0,0 @@
|
||||
services:
|
||||
nginx:
|
||||
volumes:
|
||||
- ../nginx.dev.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 5173
|
||||
+10
-34
@@ -7,57 +7,33 @@ services:
|
||||
- "8025:8025"
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
burger-network:
|
||||
lunchtime-network:
|
||||
aliases:
|
||||
- mailpit
|
||||
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: lunchtime-nginx
|
||||
lunchtime:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Containerfile
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ../nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
depends_on:
|
||||
- backend
|
||||
- frontend
|
||||
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
|
||||
- APP_ENV=development
|
||||
- LOG_LEVEL=debug
|
||||
- DB_PATH=/app/data
|
||||
- SMTP_HOST=mailpit
|
||||
- SMTP_PORT=1025
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
burger-network:
|
||||
lunchtime-network:
|
||||
aliases:
|
||||
- backend
|
||||
- app
|
||||
depends_on:
|
||||
- mailpit
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: frontend
|
||||
dockerfile: Containerfile
|
||||
container_name: lunchtime-frontend
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
burger-network:
|
||||
aliases:
|
||||
- frontend
|
||||
|
||||
networks:
|
||||
burger-network:
|
||||
lunchtime-network:
|
||||
driver: bridge
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
nginx -g 'daemon off;' &
|
||||
exec uvicorn app.main:app --host 0.0.0.0 --port 5000
|
||||
@@ -1,24 +0,0 @@
|
||||
FROM node:20-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . ./
|
||||
RUN npm run build
|
||||
|
||||
FROM node:20-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install -g http-server
|
||||
|
||||
COPY --from=build /app/dist ./
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||
CMD wget -q -O- http://localhost:8000/index.html || exit 1
|
||||
|
||||
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"]
|
||||
+10
-15
@@ -1,15 +1,19 @@
|
||||
upstream backend {
|
||||
server backend:5000;
|
||||
}
|
||||
|
||||
upstream frontend {
|
||||
server frontend:8000;
|
||||
server localhost:5000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
|
||||
# Serve frontend from nginx
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# Proxy API requests to backend
|
||||
location /api/ {
|
||||
proxy_pass http://backend/api/;
|
||||
proxy_http_version 1.1;
|
||||
@@ -21,13 +25,4 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://frontend/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user