Skip to content

Docker build fails: Golang version mismatch (1.12 vs 1.20 required) #104

@giselacb

Description

@giselacb

Bug Report

Problem

The current Dockerfile uses golang:1.12 but the code requires go 1.20 (as specified in go.mod), causing build failures.

Error

cannot load embed: cannot find module providing package embed
ERROR: failed to solve: process "/bin/sh -c go mod download && go build -o etcdkeeper.bin main.go" did not complete successfully: exit code: 1

Environment

  • Docker version: Any
  • Platform: Any

Steps to Reproduce

  1. Clone the repository
  2. Run docker build -t etcdkeeper .
  3. Build fails with Go version incompatibility

Root Cause

  • go.mod specifies go 1.20
  • Dockerfile uses FROM golang:1.12
  • Go 1.12 doesn't support modern dependencies used in the project

Proposed Solution

Update Dockerfile to use a compatible Go version:

FROM golang:1.21 AS build  # Updated from golang:1.12

Additional Improvements

  • Update Alpine version to 3.18 for security
  • Fix deprecated ENV format
  • Use JSON format for CMD

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions