diff --git a/samples/arduino-wifi/app/.dockerignore b/samples/arduino-wifi/app/.dockerignore new file mode 100644 index 00000000..74a7bf9e --- /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 852f4662..20977fc8 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: diff --git a/samples/django/app/.dockerignore b/samples/django/app/.dockerignore deleted file mode 100644 index 4cc7e000..00000000 --- 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 203cec54..00000000 --- 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 c720d76e..31cdbaad 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: 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 a0dee944..b402d6a0 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) diff --git a/samples/flask/compose.yaml b/samples/flask/compose.yaml index 4bfa1180..750ff3cd 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 32317873..00000000 --- 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"] diff --git a/samples/golang-http-form/app/.dockerignore b/samples/golang-http-form/app/.dockerignore new file mode 100644 index 00000000..74a7bf9e --- /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 dc93d178..00000000 --- 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 7ef95178..78689ebf 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