diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..e3ac708 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,23 @@ +name: Build and Push to Docker Hub + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Build Docker image + run: docker build -t ${{ secrets.DOCKER_USERNAME }}/final-python . + + - name: Push to Docker Hub + run: docker push ${{ secrets.DOCKER_USERNAME }}/final-python diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2a98fa9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Use python 3.7 +FROM python:3.7-slim + +# Prevent Python from buffering output +ENV PYTHONUNBUFFERED=1 + +# Set cwd +WORKDIR / + +# Copy dependencies file +COPY requirements.txt . + +# Downgrade pip for compatibility with Python 3.7 +RUN pip install --upgrade pip==22.3.1 + +# Install dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the app +COPY . . + +# Expose the port the app runs on +EXPOSE 5000 + +# Run the Flask app +CMD ["python", "app.py"]