naas/Containerfile
Ole-Morten Duesund 858e14a520 Initial commit: Add NaaS (No as a Service) implementation
Add complete NaaS HTTP service implementation with:
- Pure Rust implementation using only standard library
- Multiple response formats (text, JSON, XML, YAML, boolean)
- Embedded web frontend with mobile-responsive design
- Container support with Podman/Docker
- Systemd service configuration
- Health check endpoint
- CORS support

The service always responds with "no" in various formats,
optimized for minimal binary size (~1MB) and fast response times.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-27 16:42:47 +02:00

56 lines
No EOL
1 KiB
Docker

# Build stage
FROM docker.io/rust:1-alpine AS builder
# Install build dependencies
RUN apk add --no-cache musl-dev
WORKDIR /app
# Copy manifests
COPY Cargo.toml ./
# Create dummy main.rs for dependency caching
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies
RUN cargo build --release
RUN rm -rf src
# Copy source code
COPY src ./src
# Touch main.rs to ensure rebuild
RUN touch src/main.rs
# Build the application
RUN cargo build --release
# Runtime stage
FROM docker.io/alpine:latest
# Install runtime dependencies
RUN apk add --no-cache ca-certificates
# Create non-root user
RUN adduser -D -u 1000 naas
WORKDIR /app
# Copy binary from builder
COPY --from=builder /app/target/release/naas /app/naas
RUN chmod +x /app/naas
# Change ownership
RUN chown -R naas:naas /app
USER naas
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run the application
CMD ["./naas"]