Skip to content

Commit fa36f9a

Browse files
authored
Merge pull request #80 from seatable/updated-base-image
Updated base image
2 parents d7bf47a + 88c45b0 commit fa36f9a

File tree

7 files changed

+62
-44
lines changed

7 files changed

+62
-44
lines changed

.github/workflows/build-image-on-push.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,16 @@ jobs:
103103
password: ${{ secrets.DOCKERHUB_TOKEN }}
104104

105105
- name: Build image
106-
uses: docker/build-push-action@v5
106+
uses: docker/build-push-action@v6
107107
with:
108108
context: ${{ needs.init-vars.outputs.component }}
109-
# Load build result to `docker images`
110-
load: true
109+
provenance: true
110+
sbom: true
111+
push: true
111112
tags: |
112113
seatable/seatable-python-${{ needs.init-vars.outputs.component }}:commit-${{ steps.get_commit.outputs.short_sha }}
113114
seatable/seatable-python-${{ needs.init-vars.outputs.component }}:${{ needs.init-vars.outputs.image_tag_prefix }}${{ needs.init-vars.outputs.version }}
115+
${{ needs.init-vars.outputs.image_tag_prefix == '' && format('seatable/seatable-python-{0}:latest', needs.init-vars.outputs.component) || '' }}
114116
labels: |
115117
org.opencontainers.image.title=seatable/seatable-python-${{ needs.init-vars.outputs.component }}
116118
org.opencontainers.image.version=${{ needs.init-vars.outputs.image_tag_prefix }}${{ needs.init-vars.outputs.version }}
@@ -131,18 +133,4 @@ jobs:
131133
ignore-unfixed: true
132134
vuln-type: 'os,library'
133135
severity: 'CRITICAL,HIGH'
134-
env:
135-
# Use multiple repositories to limit the likelihood of encountering rate limits
136-
TRIVY_DB_REPOSITORY: ghcr.io/aquasecurity/trivy-db,public.ecr.aws/aquasecurity/trivy-db
137136

138-
- name: Push image
139-
id: push_image
140-
run: |
141-
docker push seatable/seatable-python-${{ needs.init-vars.outputs.component }}:commit-${{ steps.get_commit.outputs.short_sha }}
142-
docker push seatable/seatable-python-${{ needs.init-vars.outputs.component }}:${{ needs.init-vars.outputs.image_tag_prefix }}${{ needs.init-vars.outputs.version }}
143-
144-
- name: Push "latest" tag
145-
run: |
146-
docker tag seatable/seatable-python-${{ needs.init-vars.outputs.component }}:commit-${{ steps.get_commit.outputs.short_sha }} seatable/seatable-python-${{ needs.init-vars.outputs.component }}:latest
147-
docker push seatable/seatable-python-${{ needs.init-vars.outputs.component }}:latest
148-
if: ${{ needs.init-vars.outputs.image_tag_prefix == '' }}

runner/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM python:3.11-alpine AS compile-image
1+
ARG BASE_IMAGE="python:3.12.10-alpine@sha256:9c51ecce261773a684c8345b2d4673700055c513b4d54bc0719337d3e4ee552e"
2+
3+
FROM ${BASE_IMAGE} AS compile-image
24

35
RUN apk add --no-cache \
46
cargo \
@@ -35,9 +37,8 @@ RUN pip install --upgrade setuptools && \
3537
pip install --upgrade --user setuptools && \
3638
pip install -r requirements.txt --no-cache-dir --user
3739

38-
3940
## Runtime image
40-
FROM python:3.11-alpine AS runtime-image
41+
FROM ${BASE_IMAGE} AS runtime-image
4142

4243
RUN apk add --no-cache bash \
4344
python3-dev

runner/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
requests
2-
seatable-api==2.8.2
2+
seatable-api==3.0.0
33
dateutils
44
pyOpenSSL
55
pandas

scheduler/Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
### Compile Image
2-
FROM python:3.11-slim-bookworm AS compile-image
1+
ARG BASE_IMAGE="python:3.12-slim-bookworm@sha256:31a416db24bd8ade7dac5fd5999ba6c234d7fa79d4add8781e95f41b187f4c9a"
2+
FROM ${BASE_IMAGE} AS compile-image
33

44
# Installation of the pip packages
55
WORKDIR /opt/scheduler
66
COPY ["app/requirements.txt", "/opt/scheduler/requirements.txt"]
77
RUN pip3 install -r /opt/scheduler/requirements.txt --user
88

9-
109
### Runtime Image
11-
FROM python:3.11-slim-bookworm AS runtime-image
10+
FROM ${BASE_IMAGE} AS runtime-image
1211

1312
# Clean up && Installation of the apt packages
1413
RUN apt-get update --fix-missing && \
15-
apt-get autoremove -y && \
16-
apt-get clean && \
14+
apt-get upgrade -y && \
1715
export DEBIAN_FRONTEND=noninteractive && \
18-
apt-get install -y tzdata default-mysql-client procps cron logrotate nginx
19-
20-
# Comment this line for production
21-
# RUN apt-get install -y curl net-tools nano
16+
apt-get install -y \
17+
tzdata \
18+
default-mysql-client \
19+
procps \
20+
logrotate \
21+
cron \
22+
nginx && \
23+
apt-get autoremove -y && \
24+
apt-get clean
2225

2326
# copy compiled pip packages in runtime-image
2427
COPY --from=compile-image /root/.local /root/.local

starter/Dockerfile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
### Compile Image
2-
FROM python:3.11-slim-bookworm AS compile-image
1+
ARG BASE_IMAGE="python:3.12-slim-bookworm@sha256:31a416db24bd8ade7dac5fd5999ba6c234d7fa79d4add8781e95f41b187f4c9a"
2+
FROM ${BASE_IMAGE} AS compile-image
3+
4+
ARG DOCKER_VERSION="28.1.1"
35

46
RUN apt-get update --fix-missing && \
5-
apt-get install -y gcc
7+
apt-get upgrade -y && \
8+
apt-get install -y gcc curl bzip2 unzip
9+
10+
# Get docker binary
11+
ADD https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz /
12+
RUN tar --extract --file docker-${DOCKER_VERSION}.tgz --directory /tmp/ --strip-components 1
613

714
WORKDIR /opt/seatable-python-starter
815
COPY ["./requirements.txt", "/opt/seatable-python-starter/"]
916

1017
# Upgrade setuptools to fix vulnerabilities
1118
RUN pip install --upgrade setuptools && \
1219
pip install --upgrade --user setuptools && \
13-
pip install -r /opt/seatable-python-starter/requirements.txt --user --break-system-packages
20+
pip install -r /opt/seatable-python-starter/requirements.txt --user
1421

1522
### Runtime image
16-
FROM python:3.11-slim-bookworm AS runtime-image
23+
FROM ${BASE_IMAGE} AS runtime-image
1724

1825
RUN apt-get update --fix-missing && \
19-
apt-get autoremove -y && \
20-
apt-get clean && \
26+
apt-get upgrade -y && \
2127
export DEBIAN_FRONTEND=noninteractive && \
22-
apt-get install -y tzdata procps cron logrotate docker.io gcc curl
28+
apt-get install -y \
29+
tzdata \
30+
procps \
31+
cron \
32+
logrotate && \
33+
apt-get autoremove -y && \
34+
apt-get clean
35+
36+
COPY --from=compile-image /tmp/docker /usr/local/bin/docker
37+
RUN chmod +x /usr/local/bin/docker
2338

2439
WORKDIR /opt/seatable-python-starter
2540
COPY ["./", "./"]

starter/entrypoint.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ fi
6969
echo "** uWSGI is starting now"
7070
uwsgi --ini /opt/seatable-python-starter/uwsgi.ini 2>&1 &
7171
sleep 1
72-
if curl -IsSf http://127.0.0.1:8080/ping/ >/dev/null 2>&1; then
73-
echo "** SeaTable Python Starter ready"
74-
else
75-
echo "** Error: SeaTable Python Starter is not ready. uWSGI is not answering."
76-
fi
72+
echo "** SeaTable Python Starter ready"
7773

7874
# check cron
7975
service cron start &

starter/runner.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@
4949
TMPFS_MOUNT_SIZE_IN_BYTES = os.environ.get(
5050
"PYTHON_RUNNER_TMPFS_MOUNT_SIZE_IN_BYTES", "104857600"
5151
)
52+
DROPPED_CAPABILITIES = [
53+
cap
54+
for cap in os.environ.get("PYTHON_RUNNER_DROPPED_CAPABILITIES", "").split(",")
55+
if cap.strip()
56+
]
57+
NO_NEW_PRIVILEGES = (
58+
os.environ.get("PYTHON_RUNNER_NO_NEW_PRIVILEGES", "false").lower() == "true"
59+
)
5260
OTHER_OPTIONS = os.environ.get("PYTHON_RUNNER_OTHER_OPTIONS", "[]")
5361
try:
5462
OTHER_OPTIONS = ast.literal_eval(OTHER_OPTIONS)
@@ -308,6 +316,13 @@ def run_python(data):
308316
command.extend(
309317
["--mount", f"type=tmpfs,dst=/tmp,tmpfs-size={TMPFS_MOUNT_SIZE_IN_BYTES}"]
310318
)
319+
if DROPPED_CAPABILITIES:
320+
command.extend(
321+
f"--cap-drop={capability}" for capability in DROPPED_CAPABILITIES
322+
)
323+
if NO_NEW_PRIVILEGES:
324+
# Prevent container from gaining additional privileges
325+
command.extend(["--security-opt", "no-new-privileges"])
311326
# other options, these options are experimental, may cause failure to start script
312327
if OTHER_OPTIONS and isinstance(OTHER_OPTIONS, list):
313328
for option in OTHER_OPTIONS:

0 commit comments

Comments
 (0)