UNCLASSIFIED
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Platform One
P
Party Bus
Valkyrie
valkyrie-api
Commits
0fdd6264
Commit
0fdd6264
authored
Jul 01, 2021
by
abrichards
Browse files
optimize docker build
parent
a4693d1d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
16 deletions
+54
-16
.dockerignore
.dockerignore
+5
-3
.gitignore
.gitignore
+2
-1
Dockerfile
Dockerfile
+7
-11
Dockerfile.local
Dockerfile.local
+35
-0
README.md
README.md
+5
-1
No files found.
.dockerignore
View file @
0fdd6264
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore all files which are not go type
!**/*.go
!**/*.mod
!**/*.sum
# !**/*.go
# !**/*.mod
# !**/*.sum
testbin
\ No newline at end of file
.gitignore
View file @
0fdd6264
...
...
@@ -26,4 +26,5 @@ coverage.html
*.swo
*~
.vscode
\ No newline at end of file
.vscode
.gomodcache
Dockerfile
View file @
0fdd6264
...
...
@@ -3,25 +3,21 @@
FROM
registry.il2.dso.mil/platform-one/devops/pipeline-templates/valkyrie/golang-builder-1.6:1.0 as builder
WORKDIR
/workspace
# set go module cache
ENV
GOMODCACHE=/workspace/.gomodcache
# Copy the Go Modules manifests
COPY
go.mod go.mod
COPY
go.sum go.sum
COPY
. .
USER
root
RUN
chmod
755 go.sum
#
cache deps before building and copying source so that we don't need to re-download as much
#
and so that source changes don't invalidate our downloaded layer
#
download with json logging
#
RUN go mod download -json
RUN
go mod download
# Copy the go source
COPY
main.go main.go
COPY
driver.go driver.go
COPY
apis/ apis/
COPY
config/ config/
COPY
controllers/ controllers/
COPY
clients/ clients/
# RUN ls -al
# Build
RUN
CGO_ENABLED
=
0
GOOS
=
linux
GOARCH
=
amd64
GO111MODULE
=
on go build
-a
-o
manager main.go driver.go
# make hadolint happy. set user to non root user
USER
golanguser
...
...
Dockerfile.local
0 → 100644
View file @
0fdd6264
# NOTE: USING THIS IMAGE UNTIL registry1 credentials are added to IL2 runners
# Build the manager binary
FROM registry.il2.dso.mil/platform-one/devops/pipeline-templates/valkyrie/golang-builder-1.6:1.0 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
USER root
RUN chmod 755 go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY main.go main.go
COPY driver.go driver.go
COPY apis/ apis/
COPY config/ config/
COPY controllers/ controllers/
COPY clients/ clients/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go driver.go
# make hadolint happy. set user to non root user
USER golanguser
# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM registry.il2.dso.mil/platform-one/devops/pipeline-templates/base-image/harden-ubi8-8.4:1.0
WORKDIR /app
COPY --from=builder /workspace/manager .
USER appuser
ENTRYPOINT ["/app/manager"]
README.md
View file @
0fdd6264
## <img src="valkyrie.png" width="60"> Valkyrie Automated CICD Provisioning Tool
## Bump
## Env Variables
-
for local building and to closer simulate the pipeline set
-
from root folder of project
-
export GOMODCACHE=$(pwd)/.gomodcache
### Golang Frameworks
-
kubebuilder
-
https://book.kubebuilder.io/introduction.html
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment