From b54c393eb1be69e932db56483bbf4658017108c6 Mon Sep 17 00:00:00 2001 From: Mesut GENEZ Date: Sat, 28 Dec 2024 00:00:17 +0300 Subject: [PATCH] dockerfile --- Dockerfile | 34 ++++++++++++++++++++++++---------- docker-compose.yml | 21 --------------------- 2 files changed, 24 insertions(+), 31 deletions(-) delete mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index ce3242f..923fd82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ -# Build aşaması +# Build stage FROM golang:1.23-bullseye AS builder -# Install the necessary build tools -RUN apt-get update && apt-get install -y git +# Install necessary build tools +RUN apt-get update && apt-get install -y \ + git \ + gcc \ + g++ \ + sqlite3 \ + && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app @@ -15,18 +20,27 @@ RUN go mod download COPY . . # Build the application -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o sqlmapper . +RUN CGO_ENABLED=1 GOOS=linux go build -o sqlmapper ./cmd/sqlmapper -# Run stage +# Final stage FROM debian:bullseye-slim -# Install necessary packages for SSL certificates -RUN apt-get update && apt-get install -y ca-certificates +# Install runtime dependencies +RUN apt-get update && apt-get install -y \ + ca-certificates \ + sqlite3 \ + && rm -rf /var/lib/apt/lists/* -WORKDIR /root/ +WORKDIR /app -# Copy the built application from the builder stage +# Copy the built application from builder stage COPY --from=builder /app/sqlmapper . +COPY --from=builder /app/examples ./examples + +# Set environment variables +ENV PATH="/app:${PATH}" +ENV SQLMAPPER_LOG_LEVEL=info # Run the application -CMD ["./sqlmapper"] \ No newline at end of file +ENTRYPOINT ["./sqlmapper"] +CMD ["--help"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 8238ad6..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: '3.8' - -services: - sqlmapper: - build: - context: . - dockerfile: Dockerfile - image: mstgnz/sqlmapper:latest - container_name: sqlmapper - restart: unless-stopped - environment: - - TZ=UTC - volumes: - - ./config:/root/config - - ./data:/root/data - networks: - - sqlmapper-network - -networks: - sqlmapper-network: - driver: bridge \ No newline at end of file