From 3148a472583d735391adc3eef2dad9c9c70fdf53 Mon Sep 17 00:00:00 2001 From: skidoodle Date: Tue, 25 Jun 2024 00:11:30 +0200 Subject: [PATCH] fix(docker): ensure data persistence across container updates - Update Dockerfile to set BUILDER to /build - Update Dockerfile to set WORKDIR to /app - Update docker-compose.yml to use a named volume for iphistory service - Mount iphistory_data volume to /app directory in the container - Ensure data is preserved when pulling the latest image and recreating the container --- Dockerfile | 8 ++++---- docker-compose.yaml | 6 +++--- ip_history.txt | 0 3 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 ip_history.txt diff --git a/Dockerfile b/Dockerfile index 65ad5be..07444c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ FROM golang:alpine as builder -WORKDIR /app +WORKDIR /build COPY . . RUN go build -o iphistory . FROM alpine:latest RUN apk --no-cache add ca-certificates -WORKDIR /root/ -COPY --from=builder /app/iphistory . -COPY --from=builder /app/web ./web +WORKDIR /app/ +COPY --from=builder /build/iphistory . +COPY --from=builder /build/web ./web EXPOSE 8080 CMD ["./iphistory"] diff --git a/docker-compose.yaml b/docker-compose.yaml index 50b0632..acc1212 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,8 +8,8 @@ services: ports: - "8080:8080" volumes: - - data:/app + - iphistory_data:/app volumes: - data: - driver: local + iphistory_data: + external: false diff --git a/ip_history.txt b/ip_history.txt deleted file mode 100644 index e69de29..0000000