Fix dockerfile and makefile

This commit is contained in:
Torjus Håkestad 2021-04-10 08:12:06 +02:00
parent 4bb38a797c
commit e93d2d2c8b
2 changed files with 11 additions and 9 deletions

View File

@ -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"]

View File

@ -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)