Skip to content
Merged
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
42 changes: 42 additions & 0 deletions .github/workflows/docker-flask.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Publish Flask App Docker Image

on:
push:
branches:
- '**'

jobs:
build-and-publish:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ github.repository }}
BRANCH_TAG: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:${{ env.BRANCH_TAG }} .

- name: Run container for 10 seconds
run: |
docker run -d --name flask-test -p 5006:5006 ghcr.io/${{ github.repository }}:${{ env.BRANCH_TAG }}
sleep 10
docker ps | grep flask-test
docker stop flask-test
docker rm flask-test

- name: Push Docker image to GitHub Package Registry
run: |
docker push ghcr.io/${{ github.repository }}:${{ env.BRANCH_TAG }}
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use official Python image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy only necessary files
COPY requirements.txt ./
COPY rpgserver.py ./
COPY roomlogic.py ./
COPY usercommands.py ./
COPY world.json ./
COPY endgame.json ./
COPY templates/ ./templates/
COPY images/ ./images/

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

# Expose Flask port
EXPOSE 5006

# Run the Flask app
CMD ["python", "rpgserver.py"]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Flask