Fix Dockerfile to build Go application with correct module setup and port configuration.

This commit is contained in:
atharva.nawathe 2024-08-07 14:10:51 +05:30
parent 574ea58b95
commit 8f3a063752
1 changed files with 14 additions and 4 deletions

View File

@ -12,17 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
FROM golang:1.10.0
FROM golang:1.18 AS builder
WORKDIR /app
RUN go mod init temp-module || true
RUN go get github.com/codegangsta/negroni \
github.com/gorilla/mux \
github.com/xyproto/simpleredis/v2
WORKDIR /app
ADD ./main.go .
COPY ./main.go .
RUN CGO_ENABLED=0 GOOS=linux go build -o main .
FROM scratch
WORKDIR /app
COPY --from=0 /app/main .
COPY --from=builder /app/main .
COPY ./public/index.html public/index.html
COPY ./public/script.js public/script.js
COPY ./public/style.css public/style.css