Skip to content

Commit

Permalink
Refactor Dockerfile to make build more cacheable (#50)
Browse files Browse the repository at this point in the history
* Refactor Dockerfile to make build more cacheable

* Try an edit
  • Loading branch information
nabsul authored Mar 11, 2023
1 parent 89231a2 commit 2c49cde
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
k8s-ecr-login-renew
k8s-ecr-login-renew.*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vs
.idea
k8s-ecr-login-renew.exe
k8s-ecr-login-renew.*
k8s-ecr-login-renew
*~
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# syntax=docker/dockerfile:1
FROM golang:1.20-alpine AS build
WORKDIR /go/src/app
ADD . /go/src/app
RUN go get -d -v ./...
COPY go.mod /go/src/app/
COPY go.sum /go/src/app/
RUN go mod download

COPY . .
RUN go build -o /go/bin/app

FROM alpine:3.17
RUN addgroup -S -g 1001 appgroup && adduser -S -u 1001 -G appgroup appuser
USER appuser

COPY --from=build /go/bin/app /k8s-ecr-login-renew
CMD ["/k8s-ecr-login-renew"]
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module github.com/nabsul/k8s-ecr-login-renew
module k8s-ecr-login-renew

go 1.20

require (
github.com/aws/aws-sdk-go v1.44.219
github.com/nabsul/k8s-ecr-login-renew v1.7.1
k8s.io/api v0.26.2
k8s.io/apimachinery v0.26.2
k8s.io/client-go v0.26.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nabsul/k8s-ecr-login-renew v1.7.1 h1:M+e/S4rhBMn49yGPNUOrS+UoCr29Gbn5OqG13qDhtmA=
github.com/nabsul/k8s-ecr-login-renew v1.7.1/go.mod h1:7PONzlU4Y8Oeh3CAVtUIQ2fV43glcgV6UooJg8ugypU=
github.com/onsi/ginkgo/v2 v2.4.0 h1:+Ig9nvqgS5OBSACXNk15PLdp0U9XPYROt9CFzVdFGIs=
github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"errors"
"fmt"
"github.com/nabsul/k8s-ecr-login-renew/src/aws"
"github.com/nabsul/k8s-ecr-login-renew/src/k8s"
"k8s-ecr-login-renew/src/aws"
"k8s-ecr-login-renew/src/k8s"
"os"
"strings"
"time"
Expand Down

0 comments on commit 2c49cde

Please sign in to comment.