From e93d2d2c8b4cf862447bf2db7a53ec8591ef3a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sat, 10 Apr 2021 08:12:06 +0200 Subject: [PATCH] Fix dockerfile and makefile --- Dockerfile | 7 +++---- Makefile | 13 ++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98fe2c8..a2e1d5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,14 +16,13 @@ RUN go mod download COPY . /app RUN rm -rf /app/server/frontend COPY --from=frontend-builder /app/frontend/dist /app/web/frontend/dist -RUN CGO_ENABLED=0 make build -RUN mv build/apiary /app/apiary +RUN CGO_ENABLED=0 INSTALL_PREFIX=/app make install FROM alpine:latest RUN apk add --no-cache curl WORKDIR /app -COPY --from=builder /app/apiary.toml /app/apiary.toml -COPY --from=builder /app/apiary /app/apiary +COPY --from=builder /app/etc/apiary/apiary.toml /app/apiary.toml +COPY --from=builder /app/bin/apiary /app/apiary EXPOSE 8080 EXPOSE 2222 CMD ["/app/apiary", "serve"] \ No newline at end of file diff --git a/Makefile b/Makefile index f997f7c..ad0ec32 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD) BUILD_DIR = build/binary/current BUILD_OUTPUT = $(BUILD_DIR)/$(NAME)-$(VERSION)-$(OS)-$(ARCH) -BUILD_FLAGS = -tags embed -ldflags "-X github.uio.no/torjus/apiary.Build=$(GIT COMMIT)" -o $(BUILD_OUTPUT) +BUILD_FLAGS = -tags embed -ldflags "-X github.uio.no/torjus/apiary.Build=$(GIT_COMMIT)" -o $(BUILD_OUTPUT) GEODB_URL = https://github.com/geoacumen/geoacumen-country/raw/master/Geoacumen-Country.mmdb GEODB_PATH = honeypot/Geoacumen-Country.mmdb @@ -28,15 +28,17 @@ endif $(GEODB_PATH): curl $(GEODB_URL) -o $(GEODB_PATH) -$(BUILD_DIR): $(GEODB_PATH) +$(BUILD_DIR): mkdir -p $(BUILD_DIR) -$(BUILD_OUTPUT): $(BUILD_DIR) - go build $(BUILD_FLAGS) cmd/apiary.go +$(BUILD_OUTPUT): $(BUILD_DIR) $(GEODB_PATH) + CGO_ENABLED=0 go build $(BUILD_FLAGS) cmd/apiary.go clean: rm -rv $(BUILD_DIR) +geodb: $(GEODB_PATH) + build: $(BUILD_OUTPUT) install: build @@ -46,5 +48,6 @@ install: build install -m 755 apiary.toml $(INSTALL_ETC_DIR)/apiary.toml uninstall: - rm -rv $(INSTALL_ETC_DIR) + rm -v $(INSTALL_ETC_DIR)/apiary.toml + rmdir -v $(INSTALL_ETC_DIR) rm -v $(INSTALL_BIN_DIR)/$(NAME) \ No newline at end of file