Skip to content

Commit

Permalink
Update Build process to use /static dir
Browse files Browse the repository at this point in the history
  • Loading branch information
davemachado committed Feb 2, 2022
1 parent 94dc158 commit 989b966
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ FROM golang:1.17.6

ENV SRC_DIR=/go/src/github.com/davemachado/public-api

RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 && chmod +x /usr/local/bin/dep

ADD . $SRC_DIR
WORKDIR $SRC_DIR

RUN go build
RUN CGO_ENABLED=0 GOOS=linux go build

FROM scratch
COPY --from=0 /go/src/github.com/davemachado/public-api/public-api /public-api
COPY --from=0 /go/src/github.com/davemachado/public-api/static /static
EXPOSE 8080
ENTRYPOINT ["./public-api"]
ENTRYPOINT ["/public-api"]

7 changes: 0 additions & 7 deletions Dockerfile.scratch

This file was deleted.

13 changes: 2 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ TAG := $$(git log -1 --pretty=%h)
IMG := ${NAME}:${TAG}
LATEST := ${NAME}:latest

ENV_FLAGS := CGO_ENABLED=0 GOOS=linux

all: build

dep:
Expand All @@ -14,17 +12,10 @@ test:
@go test -race -coverprofile=coverage.txt -covermode=atomic -v ./...

build: dep test html
@${ENV_FLAGS} go build -o public-api
@docker build -t ${IMG} . -f Dockerfile.scratch
@docker build -t ${IMG} .
@docker tag ${IMG} ${LATEST}

push: login
@docker push ${NAME}

login:
@docker login -u ${DOCKER_USER} -p${DOCKER_PASS}

data:
data: html
@curl -o /tmp/public-apis.md https://raw.githubusercontent.com/public-apis/public-apis/master/README.md
@./md2json /tmp/public-apis.md > entries.json
@rm /tmp/public-apis.md
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func main() {
}
// If the file does not exist, create it. Otherwise, append to the file.
f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
}
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 989b966

Please sign in to comment.