update:
This commit is contained in:
@@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: Deploy to Lightsail VM
|
- name: Deploy to Lightsail VM
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.LIGHTSAIL_HOST }}
|
host: ${{ vars.LIGHTSAIL_DEPLOY_HOST }}
|
||||||
username: ${{ secrets.LIGHTSAIL_USERNAME }}
|
username: ${{ secrets.LIGHTSAIL_USERNAME }}
|
||||||
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
|
key: ${{ secrets.LIGHTSAIL_SSH_KEY }}
|
||||||
port: ${{ vars.LIGHTSAIL_PORT }}
|
port: ${{ vars.LIGHTSAIL_PORT }}
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
--exclude='__pycache__' \
|
--exclude='__pycache__' \
|
||||||
--exclude='*.pyc' \
|
--exclude='*.pyc' \
|
||||||
--exclude='.env' \
|
--exclude='.env' \
|
||||||
./ "$DEPLOY_DIR/"
|
./workspace/sprint_1_2/CODEBASE/deps/implementation/CD_server/ "$DEPLOY_DIR/"
|
||||||
|
|
||||||
echo "[deploy] Building CD server Docker image"
|
echo "[deploy] Building CD server Docker image"
|
||||||
sudo -u deploy docker compose -f "$DEPLOY_DIR/docker-compose.yml" build --no-cache
|
sudo -u deploy docker compose -f "$DEPLOY_DIR/docker-compose.yml" build --no-cache
|
||||||
|
|||||||
@@ -1,17 +1,33 @@
|
|||||||
FROM python:3.12-slim
|
# Stage 1: Builder
|
||||||
|
FROM python:3.12-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
COPY main.py config.py docker_ops.py schemas.py config.yaml ./
|
# Simply downloads the pre-compiled wheels from PyPI without needing a compiler
|
||||||
|
RUN pip wheel --no-cache-dir --wheel-dir=/app/wheels -r requirements.txt
|
||||||
|
|
||||||
RUN groupadd -g 998 docker || true
|
|
||||||
RUN useradd -m -u 998 -g docker appuser
|
# Stage 2: Final Runtime
|
||||||
|
FROM python:3.12-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 1. Setup system user first (Cached forever because it doesn't rely on files)
|
||||||
|
RUN groupadd -g 998 docker || true \
|
||||||
|
&& useradd -l -m -u 998 -g docker appuser
|
||||||
|
|
||||||
|
# 2. Bring in the wheels
|
||||||
|
COPY --from=builder /app/wheels /app/wheels
|
||||||
|
|
||||||
|
# 3. Install dependencies (Only runs if requirements.txt changed)
|
||||||
|
RUN pip install --no-cache-dir --no-index --find-links=/app/wheels /app/wheels/*.whl \
|
||||||
|
&& rm -rf /app/wheels
|
||||||
|
|
||||||
|
# 4. Copy code files
|
||||||
|
COPY --chown=appuser:docker main.py config.py docker_ops.py schemas.py config.yaml ./
|
||||||
|
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
EXPOSE 3333
|
EXPOSE 3333
|
||||||
|
CMD ["python", "main.py"]
|
||||||
CMD ["python", "main.py"]
|
|
||||||
Reference in New Issue
Block a user