Skip to content

Docker build fail #73

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
58 changes: 13 additions & 45 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,22 @@ name: docker-build

on:
push:
branches:
- 'dev'
- 'main'
workflow_dispatch:

jobs:
# build container
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: cohenaj194/flask-test

# # push container
# restart-deployment:
# runs-on: ubuntu-latest # Specifies the runner environment
# needs: docker

# steps:
# - name: Checkout code
# uses: actions/checkout@v2 # Checks out your repository under $GITHUB_WORKSPACE
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# - name: Set up Kubectl
# uses: azure/setup-kubectl@v3 # Updated to version 3 to fix the vulnerability
# with:
# version: 'v1.20.0' # Specify the version of kubectl you want to use

# - name: Configure Kubeconfig
# env:
# KUBECONFIG_STAGING: ${{ secrets.KUBECONFIG_STAGING }} # Uses the secret encoded in base64
# run: |
# echo "$KUBECONFIG_STAGING" | base64 -d > kubeconfig
# export KUBECONFIG=$(pwd)/kubeconfig

# - name: Rollout Restart Deployment
# run: kubectl rollout restart deployment flask-test --kubeconfig kubeconfig
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Checkout code
uses: actions/checkout@v4

- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: false
26 changes: 9 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# start by pulling the python image
FROM python:3.11-alpine
# syntax=docker/dockerfile:1

# copy the requirements file into the image
COPY ./ /app/
# Alpine is chosen for its small footprint
# compared to Ubuntu

Comment on lines +3 to +4
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistency between comments and actual base image.

The comments mention using Alpine for its small footprint, but the actual base image is python:slim-bookworm (Debian-based). Either update the comments to reflect the current choice or switch back to Alpine if that's the intended base image.

-# Alpine is chosen for its small footprint
-# compared to Ubuntu
-
-FROM python:slim-bookworm
+# Debian slim is chosen for better PyQt5 compatibility
+# while maintaining a relatively small footprint
+
+FROM python:slim-bookworm

Also applies to: 6-6

# switch working directory
WORKDIR /app
FROM python:slim-bookworm

# install the dependencies and packages in the requirements file
RUN pip install -r requirements.txt
# install packages
RUN pip3 install tenacity requests PyQt5.asdf \
&& apt-get update \
&& apt-get install -y libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*

Comment on lines +9 to +12
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix critical package installation issues.

Several issues need to be addressed:

  1. PyQt5.asdf package doesn't exist in PyPI, causing the Docker build to fail
  2. Package versions aren't pinned, which could lead to inconsistent builds
  3. pip is outdated (24.3.1)

Apply this diff to fix the issues:

-RUN pip3 install tenacity requests PyQt5.asdf \
+# Update pip first
+RUN python -m pip install --no-cache-dir --upgrade pip && \
+    pip3 install --no-cache-dir \
+    tenacity==8.2.3 \
+    requests==2.31.0 \
+    PyQt5==5.15.10 \
     && apt-get update \
     && apt-get install -y libglib2.0-0 \
     && rm -rf /var/lib/apt/lists/*

Note: I've added specific versions for the Python packages. Please verify these versions match your requirements.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN pip3 install tenacity requests PyQt5.asdf \
&& apt-get update \
&& apt-get install -y libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Update pip first
RUN python -m pip install --no-cache-dir --upgrade pip && \
pip3 install --no-cache-dir \
tenacity==8.2.3 \
requests==2.31.0 \
PyQt5==5.15.10 \
&& apt-get update \
&& apt-get install -y libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
🧰 Tools
🪛 GitHub Actions: docker-build

[error] 9-12: Failed to install PyQt5.asdf package: Package not found in PyPI repository. This is causing the Docker build to fail.


[warning] 9-9: pip is outdated (24.3.1). Update recommended to version 25.0

# configure the container to run in an executed manner
ENV FLASK_APP=app.py
EXPOSE 5000
ENTRYPOINT [ "python" ]
CMD ["app.py"]

## DOCKER COMMANDS
# docker build -t flask-test .
# docker run -dit --name test -p 5000:5000 flask-test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# temp-fe

A temporary frontend for new api functions, before we can redo them in react.
A temporary frontend for new api functions, before we can redo them in react

# deployment

Expand Down
Loading