Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test deploy #660

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ name: Deploy

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'production'
ref:
description: 'Git reference to deploy'
required: false

jobs:
build:
Expand All @@ -10,10 +18,12 @@ jobs:
permissions:
contents: read
packages: write
env:
VITE_DEBUGGER_URL: ${{ secrets.DEBUGGER_URL }}
strategy:
fail-fast: false
matrix:
component: [client]
component: [client, debugger]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -46,6 +56,8 @@ jobs:
needs: [build]
concurrency: production
environment: production
env:
VITE_DEBUGGER_URL: ${{ secrets.DEBUGGER_URL }}

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import checker from 'vite-plugin-checker';
export default defineConfig({
plugins: [react(), tsconfigPaths(), checker({ typescript: true })],
build: { outDir: 'build' },
server: { port: 3000 },
server: { port: 3000, host: '0.0.0.0' },
});
89 changes: 54 additions & 35 deletions debugger/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,52 +1,71 @@
FROM ubuntu
FROM ubuntu:latest

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y; apt-get install -y build-essential gdb curl git libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
# Set up APT custom configurations
RUN echo "Acquire::http::Pipeline-Depth 0;" > /etc/apt/apt.conf.d/99custom && \
echo "Acquire::http::No-Cache true;" >> /etc/apt/apt.conf.d/99custom && \
echo "Acquire::BrokenProxy true;" >> /etc/apt/apt.conf.d/99custom

# Install python3 to run the backend server
RUN curl https://pyenv.run | bash
# Install dependencies
RUN apt-get update && apt-get upgrade -y --fix-missing \
&& apt-get install -y \
build-essential \
gdb \
curl \
git \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev \
python3 \
python3-pip \
python3-venv \
python-is-python3 \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Setup pyenv and install Python
ENV HOME="/root"
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/bin:${PATH}"
# The following env var is needed to allow gdb to run our Python packages
# installed from requirements.txt
ENV PYTHONPATH="/root/.pyenv/versions/3.11.3/lib/python3.11/site-packages:${PYTHONPATH}"
ENV PYENV_ROOT="$HOME/.pyenv"
ENV PATH="$PYENV_ROOT/bin:$PATH"

ENV PYTHON_VERSION=3.11.3

# The following env var is needed to allow gdb to run our Python packages
# installed from requirements.txt
ENV PYTHONPATH="${PYENV_ROOT}/versions/${PYTHON_VERSION}/lib/python3.11/site-packages:${PYTHONPATH}"

RUN pyenv install ${PYTHON_VERSION}
RUN pyenv global ${PYTHON_VERSION}
RUN curl https://pyenv.run | bash && \
pyenv install 3.11.3 && \
pyenv global 3.11.3

# Install Python packages in a virtual environment
COPY requirements.txt .
RUN pyenv exec pip3 install -r requirements.txt
RUN python3 -m venv /venv && \
/venv/bin/pip install --upgrade pip && \
/venv/bin/pip install -r requirements.txt

# Setup nvm and install Node.js
ENV NODE_VERSION=20.0.0
RUN apt install -y curl
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN node --version
RUN npm --version
ENV NVM_DIR="$HOME/.nvm"
ENV PATH="$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH"

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash && \
. "$NVM_DIR/nvm.sh" && \
nvm install $NODE_VERSION && \
nvm use $NODE_VERSION && \
nvm alias default $NODE_VERSION

# Install global npm packages
RUN npm install -g nodemon

WORKDIR /app

COPY . .

EXPOSE 8000

# `python3 -u` option to prevent buffering output of print statements
# in the python server. Print to docker logs immediately. For easier
# debugging.
CMD [ "nodemon", "--exec", "pyenv", "exec", "python3", "-u", "src/server.py"]
# Command to run the application
CMD ["/venv/bin/python3", "-u", "src/server.py"]
25 changes: 25 additions & 0 deletions debugger/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ===== Stage 1: Base Image with Python Installed =====
FROM python:3.11-slim as base
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ===== Stage 2: Application Layer =====
FROM base as final

# Copy application code
COPY . .

# Set a non-root user and switch to it
RUN useradd -m myuser
USER myuser

# Set the port the app runs on
EXPOSE 8000

# Command to run your app
CMD ["python3", "-u", "src/server.py"]
12 changes: 12 additions & 0 deletions deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sudo curl -L "https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose


sudo apt-get update
sudo apt-get install docker.io -y
sudo systemctl start docker


rsync -avz --exclude 'debugger/src/__pycache__' --exclude 'client/node_modules' --exclude '.git' --exclude '.env' \
-e "ssh -i ~/.ssh/struct-deploy.pem" \
. [email protected]:~/app
7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ services:
- '8000:8000'
volumes:
- ./debugger/src:/app/src
environment:
- PYTHONPATH=/app
network_mode: "bridge"
logging:
options:
max-size: "10m"
max-file: "3"
server:
build:
context: server
Expand Down