-
Notifications
You must be signed in to change notification settings - Fork 12
Modified dockerfile.prod #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,46 @@ | ||
| FROM debian:bullseye as builder | ||
|
|
||
| ENV TZ=America/New_York | ||
| ENV PATH=/go/bin:$PATH | ||
| ENV GOROOT=/go | ||
| ENV GOPATH=/src/go | ||
|
|
||
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &&\ | ||
| mkdir /go &&\ | ||
| mkdir -p /src/go &&\ | ||
| apt update &&\ | ||
| apt -y install build-essential &&\ | ||
| apt -y install gdal-bin gdal-data libgdal-dev &&\ | ||
| apt -y install wget &&\ | ||
| wget https://golang.org/dl/go1.19.5.linux-amd64.tar.gz -P / &&\ | ||
| tar -xvzf /go1.19.5.linux-amd64.tar.gz -C / &&\ | ||
| apt -y install vim &&\ | ||
| apt -y install git | ||
|
|
||
| WORKDIR /app | ||
| RUN git clone https://github.com/USACE/go-consequences.git | ||
| WORKDIR /app/go-consequences | ||
| RUN go mod download | ||
| RUN go mod tidy | ||
| RUN go build main.go | ||
|
|
||
|
|
||
| FROM ghcr.io/osgeo/gdal:ubuntu-full-3.8.3 as prod | ||
| RUN apt update &&\ | ||
| apt -y install build-essential &&\ | ||
| apt -y install pkg-config &&\ | ||
| apt -y install gdal-bin gdal-data libgdal-dev | ||
| WORKDIR /app | ||
| COPY --from=builder /app/go-consequences/main . | ||
| ENTRYPOINT ["/main"] | ||
| # Stage 1: Builder | ||
| FROM debian:bullseye AS builder | ||
|
|
||
| ENV TZ=America/New_York | ||
| ENV PATH=/go/bin:$PATH | ||
| ENV GOROOT=/go | ||
| ENV GOPATH=/src/go | ||
|
|
||
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &&\ | ||
| mkdir -p /go &&\ | ||
| mkdir -p /src/go &&\ | ||
| apt update &&\ | ||
| apt -y install build-essential &&\ | ||
| apt -y install libgdal-dev &&\ | ||
| apt -y install gdal-bin &&\ | ||
| apt -y install gdal-data &&\ | ||
| apt -y install wget &&\ | ||
| wget https://golang.org/dl/go1.19.5.linux-amd64.tar.gz -P / &&\ | ||
| tar -xvzf /go1.19.5.linux-amd64.tar.gz -C / &&\ | ||
| apt -y install vim &&\ | ||
| apt -y install git | ||
|
|
||
| WORKDIR /app | ||
| RUN git clone https://github.com/USACE/go-consequences.git | ||
| WORKDIR /app/go-consequences | ||
| RUN go mod download | ||
| RUN go mod tidy | ||
| RUN go build -o main . | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ill have to research this tag now. |
||
|
|
||
| # Stage 2: Production | ||
| FROM ghcr.io/osgeo/gdal:ubuntu-full-3.8.3 AS prod | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this all looks much better, not doing build essential, and pulling the libraries you actually need. super cool great job. will have to test it |
||
|
|
||
| # Move the executable from build to production | ||
| WORKDIR /app | ||
| COPY --from=builder /app/go-consequences/main ./ | ||
|
|
||
| # Install necessary GDAL libraries | ||
| RUN apt update && \ | ||
| apt install -y libgdal-dev && \ | ||
| ln -s /usr/lib/libgdal.so /usr/lib/libgdal.so.28 && \ | ||
| ldconfig | ||
|
|
||
| # Verify library dependencies for debugging | ||
| RUN ldd ./main | ||
|
|
||
| ENTRYPOINT ["/app/main"] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vim isnt necessary for the builder