Skip to content

Commit

Permalink
Refactor/k8s (#169)
Browse files Browse the repository at this point in the history
* 🔧refactor: Migrate to python 3.11

* 🔧refactor: outputs

* 🔧refactor: outputs symbol colors

* 🔧refactor: outputs symbol colors update in place

* 🔧refactor: deploy set pagination and search

* 🔧refactor: add stack pagination and search

* 🔧refactor: add pagination and search component js

* 🔧refactor: add pagination and search component js for users

* 🐛fix: edit deploy

* 🐛fix: edit users

* 🐛fix: add destroy for plan UI

* 🔧refactor: stacks forms

* 🔧refactor: stacks forms variables

* 🔧refactor: Dockerfiles for use asdf and python3.11

* 🔧refactor: github action bump version

* 🔧refactor: k8s images
  • Loading branch information
D10S0VSkY-OSS authored Nov 11, 2023
1 parent df1936b commit f0225d6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 67 deletions.
2 changes: 1 addition & 1 deletion play-with-sld/kubernetes/k8s/sld-api-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
- name: api-backend
image: d10s0vsky/sld-api:latest
imagePullPolicy: Always
command: ["python3", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
command: ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
ports:
- containerPort: 8000
livenessProbe:
Expand Down
45 changes: 24 additions & 21 deletions sld-api-backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,43 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV TZ=Europe/Madrid

# Set up working directory
WORKDIR /app
ADD ./requirements.txt /app/requirements.txt

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Set timezone
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

# Install dependencies including build tools
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev pkg-config libmysqlclient-dev

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Install asdf, Python plugin, and Python version
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
# Set up working directory
WORKDIR /app

# Change to user 'sld'
USER sld

SHELL ["/bin/bash", "-c"]
# Install asdf under user 'sld'
RUN git clone https://github.com/asdf-vm/asdf.git /home/sld/.asdf --branch v0.10.0 && \
echo '. /home/sld/.asdf/asdf.sh' >> /home/sld/.bashrc && \
echo '. /home/sld/.asdf/completions/asdf.bash' >> /home/sld/.bashrc

RUN . $HOME/.asdf/asdf.sh && \
# Install Python using asdf
SHELL ["/bin/bash", "-l", "-c"]
RUN . /home/sld/.asdf/asdf.sh && \
asdf plugin add python && \
asdf install python 3.11.6 && \
asdf global python 3.11.6

# Switch back to root to perform privileged operations
USER root

# Install Python packages
RUN . $HOME/.asdf/asdf.sh && \
python -m pip install --upgrade pip setuptools && \
python -m pip install --no-cache-dir -r requirements.txt
# Add the requirements file and install Python packages
ADD ./requirements.txt /app/requirements.txt
RUN chown sld:sld /app/requirements.txt && \
su - sld -c ". /home/sld/.asdf/asdf.sh && python -m pip install --upgrade pip setuptools && python -m pip install --no-cache-dir -r /app/requirements.txt"

# Clean up
RUN apt-get clean autoclean && \
Expand All @@ -48,7 +51,7 @@ RUN apt-get clean autoclean && \

# Add the rest of the application
ADD . /app/
RUN chown -R sld /app
RUN chown -R sld:sld /app

# Switch to user
# Switch to user 'sld' for runtime
USER sld
47 changes: 25 additions & 22 deletions sld-dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,43 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV TZ=Europe/Madrid

# Set up working directory
WORKDIR /app
ADD ./requirements.txt /app/requirements.txt

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Set timezone
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

# Install dependencies including build tools
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev pkg-config libmysqlclient-dev

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Set up working directory
WORKDIR /app

# Install asdf, Python plugin, and Python version
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
# Change to user 'sld'
USER sld

SHELL ["/bin/bash", "-c"]
# Install asdf under user 'sld'
RUN git clone https://github.com/asdf-vm/asdf.git /home/sld/.asdf --branch v0.10.0 && \
echo '. /home/sld/.asdf/asdf.sh' >> /home/sld/.bashrc && \
echo '. /home/sld/.asdf/completions/asdf.bash' >> /home/sld/.bashrc

RUN . $HOME/.asdf/asdf.sh && \
# Install Python using asdf
SHELL ["/bin/bash", "-l", "-c"]
RUN . /home/sld/.asdf/asdf.sh && \
asdf plugin add python && \
asdf install python 3.11.6 && \
asdf global python 3.11.6

# Switch back to root to perform privileged operations
USER root

# Install Python packages
RUN . $HOME/.asdf/asdf.sh && \
python -m pip install --upgrade pip setuptools && \
python -m pip install --no-cache-dir -r requirements.txt
# Add the requirements file and install Python packages
ADD ./requirements.txt /app/requirements.txt
RUN chown sld:sld /app/requirements.txt && \
su - sld -c ". /home/sld/.asdf/asdf.sh && python -m pip install --upgrade pip setuptools && python -m pip install --no-cache-dir -r /app/requirements.txt"

# Clean up
RUN apt-get clean autoclean && \
Expand All @@ -48,7 +51,7 @@ RUN apt-get clean autoclean && \

# Add the rest of the application
ADD . /app/
RUN chown -R sld /app
RUN chown -R sld:sld /app

# Switch to user
USER sld
# Switch to user 'sld' for runtime
USER sld
50 changes: 27 additions & 23 deletions sld-remote-state/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,43 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV TZ=Europe/Madrid

# Set up working directory
WORKDIR /app
ADD ./requirements.txt /app/requirements.txt

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Set timezone
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime

# Install dependencies including build tools
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev
apt-get -yq install curl git zip tzdata build-essential libssl-dev libffi-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev pkg-config libmysqlclient-dev

# Create a user and group
RUN groupadd --gid 10000 sld && \
useradd --uid 10000 --gid sld --shell /bin/bash --create-home sld

# Install asdf, Python plugin, and Python version
RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0 && \
echo '. $HOME/.asdf/asdf.sh' >> ~/.bashrc && \
echo '. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
# Set up working directory
WORKDIR /app

SHELL ["/bin/bash", "-c"]
# Change to user 'sld'
USER sld

# Install asdf under user 'sld'
RUN git clone https://github.com/asdf-vm/asdf.git /home/sld/.asdf --branch v0.10.0 && \
echo '. /home/sld/.asdf/asdf.sh' >> /home/sld/.bashrc && \
echo '. /home/sld/.asdf/completions/asdf.bash' >> /home/sld/.bashrc

RUN . $HOME/.asdf/asdf.sh && \
# Install Python using asdf
SHELL ["/bin/bash", "-l", "-c"]
RUN . /home/sld/.asdf/asdf.sh && \
asdf plugin add python && \
asdf install python 3.11.6 && \
asdf global python 3.11.6

# Switch back to root to perform privileged operations
USER root

# Install Python packages
RUN . $HOME/.asdf/asdf.sh && \
python -m pip install --upgrade pip setuptools && \
python -m pip install --no-cache-dir -r requirements.txt
# Add the requirements file and install Python packages
ADD ./requirements.txt /app/requirements.txt
RUN chown sld:sld /app/requirements.txt && \
su - sld -c ". /home/sld/.asdf/asdf.sh && python -m pip install --upgrade pip setuptools && python -m pip install --no-cache-dir -r /app/requirements.txt"

# Clean up
RUN apt-get clean autoclean && \
Expand All @@ -47,7 +51,7 @@ RUN apt-get clean autoclean && \

# Add the rest of the application
ADD . /app/
RUN chown -R sld /app
RUN chown -R sld:sld /app

# Switch to user
USER sld
# Switch to user 'sld' for runtime
USER sld

0 comments on commit f0225d6

Please sign in to comment.