From ac7129099c2446d72a548cc6ee67c91251d14dc1 Mon Sep 17 00:00:00 2001 From: Kevin Vo Date: Tue, 22 Jul 2025 16:56:33 -0700 Subject: [PATCH 1/5] Working arduino-wifi railpack --- samples/arduino-wifi/app/.dockerignore | 27 +++++++++++++++++++ .../app/{Dockerfile => Dockerfile.dev} | 0 .../app/{web_server.py => app.py} | 0 samples/arduino-wifi/compose.yaml | 1 - 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 samples/arduino-wifi/app/.dockerignore rename samples/arduino-wifi/app/{Dockerfile => Dockerfile.dev} (100%) rename samples/arduino-wifi/app/{web_server.py => app.py} (100%) diff --git a/samples/arduino-wifi/app/.dockerignore b/samples/arduino-wifi/app/.dockerignore new file mode 100644 index 000000000..74a7bf9e0 --- /dev/null +++ b/samples/arduino-wifi/app/.dockerignore @@ -0,0 +1,27 @@ +# Default .dockerignore file for Defang +**/__pycache__ +**/.direnv +**/.DS_Store +**/.envrc +**/.git +**/.github +**/.idea +**/.next +**/.vscode +**/compose.*.yaml +**/compose.*.yml +**/compose.yaml +**/compose.yml +**/docker-compose.*.yaml +**/docker-compose.*.yml +**/docker-compose.yaml +**/docker-compose.yml +**/node_modules +**/Thumbs.db +Dockerfile +*.Dockerfile +# Ignore our own binary, but only in the root to avoid ignoring subfolders +defang +defang.exe +# Ignore our project-level state +.defang \ No newline at end of file diff --git a/samples/arduino-wifi/app/Dockerfile b/samples/arduino-wifi/app/Dockerfile.dev similarity index 100% rename from samples/arduino-wifi/app/Dockerfile rename to samples/arduino-wifi/app/Dockerfile.dev diff --git a/samples/arduino-wifi/app/web_server.py b/samples/arduino-wifi/app/app.py similarity index 100% rename from samples/arduino-wifi/app/web_server.py rename to samples/arduino-wifi/app/app.py diff --git a/samples/arduino-wifi/compose.yaml b/samples/arduino-wifi/compose.yaml index 852f46625..20977fc8f 100644 --- a/samples/arduino-wifi/compose.yaml +++ b/samples/arduino-wifi/compose.yaml @@ -3,7 +3,6 @@ services: restart: unless-stopped build: context: ./app - dockerfile: Dockerfile deploy: resources: reservations: From 7e92cd5da0425a463c775c139a1cf24437bdd7fb Mon Sep 17 00:00:00 2001 From: Kevin Vo Date: Tue, 22 Jul 2025 17:23:12 -0700 Subject: [PATCH 2/5] Working fastapi sample --- samples/fastapi/fastapi/{Dockerfile => Dockerfile.dev} | 0 samples/fastapi/fastapi/main.py | 4 ++++ 2 files changed, 4 insertions(+) rename samples/fastapi/fastapi/{Dockerfile => Dockerfile.dev} (100%) diff --git a/samples/fastapi/fastapi/Dockerfile b/samples/fastapi/fastapi/Dockerfile.dev similarity index 100% rename from samples/fastapi/fastapi/Dockerfile rename to samples/fastapi/fastapi/Dockerfile.dev diff --git a/samples/fastapi/fastapi/main.py b/samples/fastapi/fastapi/main.py index a0dee9442..b402d6a01 100644 --- a/samples/fastapi/fastapi/main.py +++ b/samples/fastapi/fastapi/main.py @@ -32,3 +32,7 @@ async def delete_todo(todo_id: int): global todos todos = [todo for todo in todos if todo.id != todo_id] return RedirectResponse(url="/", status_code=303) + +if __name__ == "__main__": + import uvicorn + uvicorn.run(app, host="0.0.0.0", port=8000) From 2230d750158163dd4278fa570826c299af37966f Mon Sep 17 00:00:00 2001 From: Kevin Vo Date: Wed, 23 Jul 2025 15:56:37 -0700 Subject: [PATCH 3/5] flask sample railpack --- samples/flask/compose.yaml | 1 - samples/flask/flask/Dockerfile | 26 -------------------------- 2 files changed, 27 deletions(-) delete mode 100644 samples/flask/flask/Dockerfile diff --git a/samples/flask/compose.yaml b/samples/flask/compose.yaml index 4bfa1180d..750ff3cd9 100644 --- a/samples/flask/compose.yaml +++ b/samples/flask/compose.yaml @@ -3,7 +3,6 @@ services: restart: unless-stopped build: context: ./flask - dockerfile: Dockerfile deploy: resources: reservations: diff --git a/samples/flask/flask/Dockerfile b/samples/flask/flask/Dockerfile deleted file mode 100644 index 323178731..000000000 --- a/samples/flask/flask/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# Use an official Python runtime as a base image -FROM python:3.11-slim - -# Set the working directory to /app -WORKDIR /app - -# Install required packages -RUN apt-get update -qq \ - && apt-get install -y --no-install-recommends \ - build-essential \ - python3-dev \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Copy the current directory contents into the container at /app -COPY . /app - -# Install any needed packages specified in requirements.txt -COPY requirements.txt /app/ -RUN pip install --no-cache-dir -r requirements.txt - -# Make port 5000 available to the world outside this container -EXPOSE 5000 - -# Run app.py when the container launches -CMD ["python", "app.py"] From 04c407e94f7e12e0793dbbfbe50e25614a5f393d Mon Sep 17 00:00:00 2001 From: Kevin Vo Date: Thu, 24 Jul 2025 09:42:07 -0700 Subject: [PATCH 4/5] django railpack working --- samples/django/app/.dockerignore | 31 ------------------------------- samples/django/app/Dockerfile | 27 --------------------------- samples/django/compose.yaml | 2 +- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 samples/django/app/.dockerignore delete mode 100644 samples/django/app/Dockerfile diff --git a/samples/django/app/.dockerignore b/samples/django/app/.dockerignore deleted file mode 100644 index 4cc7e000b..000000000 --- a/samples/django/app/.dockerignore +++ /dev/null @@ -1,31 +0,0 @@ -# Ignore Python bytecode files -__pycache__ -*.pyc -*.pyo -*.pyd -*.pyc.so - -# Ignore all log files -*.log - -# Ignore local configuration files -local_settings.py - -# Ignore test and coverage directories -htmlcov/ -.coverage -.tox/ - -# Ignore database files -*.sqlite3 - -# Ignore media files -media/ - -# Ignore all .env files -*.env - -# Ignore all .DS_Store files (Mac OS) -.DS_Store - -.venv/ \ No newline at end of file diff --git a/samples/django/app/Dockerfile b/samples/django/app/Dockerfile deleted file mode 100644 index 203cec54d..000000000 --- a/samples/django/app/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -# Use an official Python runtime as a parent image -FROM python:3.11-slim - -RUN apt-get update -qq \ - && apt-get install -y curl \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -# Set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# Set work directory -WORKDIR /code - -# Install dependencies -COPY requirements.txt /code/ -RUN pip install --no-cache-dir -r requirements.txt - -# Copy project -COPY . /code/ - -# Collect static files -RUN python manage.py collectstatic --noinput - -# Start server -CMD python manage.py migrate && python manage.py createsuperauto && gunicorn defang_sample.wsgi:application --bind 0.0.0.0:8000 diff --git a/samples/django/compose.yaml b/samples/django/compose.yaml index c720d76eb..31cdbaad3 100644 --- a/samples/django/compose.yaml +++ b/samples/django/compose.yaml @@ -3,13 +3,13 @@ services: restart: unless-stopped build: context: ./app - dockerfile: Dockerfile ports: - mode: ingress target: 8000 # published: 8000 # uncomment for local dev environment: - DEBUG=False # set to "True" for local dev + command: ["python manage.py migrate && python manage.py createsuperauto && gunicorn defang_sample.wsgi:application --bind 0.0.0.0:8000"] #deploy: # resources: # reservations: From 6b126bb4df92a784485db1cc3b0b7173e5319c8f Mon Sep 17 00:00:00 2001 From: Kevin Vo Date: Fri, 25 Jul 2025 14:20:34 -0700 Subject: [PATCH 5/5] Working golang-http-form sample --- samples/golang-http-form/app/.dockerignore | 27 +++++++++++++++++++ samples/golang-http-form/app/Dockerfile | 31 ---------------------- samples/golang-http-form/compose.yaml | 1 - 3 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 samples/golang-http-form/app/.dockerignore delete mode 100644 samples/golang-http-form/app/Dockerfile diff --git a/samples/golang-http-form/app/.dockerignore b/samples/golang-http-form/app/.dockerignore new file mode 100644 index 000000000..74a7bf9e0 --- /dev/null +++ b/samples/golang-http-form/app/.dockerignore @@ -0,0 +1,27 @@ +# Default .dockerignore file for Defang +**/__pycache__ +**/.direnv +**/.DS_Store +**/.envrc +**/.git +**/.github +**/.idea +**/.next +**/.vscode +**/compose.*.yaml +**/compose.*.yml +**/compose.yaml +**/compose.yml +**/docker-compose.*.yaml +**/docker-compose.*.yml +**/docker-compose.yaml +**/docker-compose.yml +**/node_modules +**/Thumbs.db +Dockerfile +*.Dockerfile +# Ignore our own binary, but only in the root to avoid ignoring subfolders +defang +defang.exe +# Ignore our project-level state +.defang \ No newline at end of file diff --git a/samples/golang-http-form/app/Dockerfile b/samples/golang-http-form/app/Dockerfile deleted file mode 100644 index dc93d1787..000000000 --- a/samples/golang-http-form/app/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# Use an official Go runtime as a parent image -FROM golang:1.20 as builder - -# Set the working directory in the builder container -WORKDIR /src - -# Copy go.mod and go.sum files to the workspace -COPY go.mod go.sum ./ - -# Download all dependencies. -RUN go mod download - -# Copy the source from the current directory to the working Directory in the builder container -COPY . . - -# Build the Go app -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main . - -# Start a new stage from scratch -FROM golang:1.20 - -WORKDIR /root/ - -# Copy the binary from builder -COPY --from=builder /src/main . - -# Expose port 8080 to the world outside this container -EXPOSE 8080 - -# Run the binary -ENTRYPOINT ["./main"] diff --git a/samples/golang-http-form/compose.yaml b/samples/golang-http-form/compose.yaml index 7ef951782..78689ebf6 100644 --- a/samples/golang-http-form/compose.yaml +++ b/samples/golang-http-form/compose.yaml @@ -3,7 +3,6 @@ services: restart: unless-stopped build: context: ./app - dockerfile: Dockerfile ports: - mode: ingress target: 8080