This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"syscall" | |
"golang.org/x/sys/unix" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
GOOS=linux go build -o app.o | |
eval $(minikube docker-env) | |
docker build -t mlockex:latest . | |
kubectl --context=minikube delete pod mlockex | |
kubectl --context=minikube apply -f pod.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.8 | |
RUN apk add libcap && \ | |
mkdir -p /home/appuser && \ | |
addgroup -S app && \ | |
adduser -u 1000 -S -h /home/appuser -G app appuser | |
WORKDIR /home/appuser | |
COPY app.o . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.8 | |
RUN mkdir -p /home/appuser && \ | |
addgroup -S app && \ | |
adduser -u 1000 -S -h /home/appuser -G app appuser | |
WORKDIR /home/appuser | |
COPY app.o . | |
RUN chown -R appuser:app /home/appuser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: mlockex | |
spec: | |
containers: | |
- name: mlockex | |
image: mlockex:latest | |
imagePullPolicy: IfNotPresent | |
securityContext: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#golang 1.12 and alpine 3.9 should work fine also | |
FROM golang:1.11.4-alpine3.8 | |
# add dev dependencies | |
RUN apk add --no-cache \ | |
bash \ | |
build-base \ | |
coreutils \ | |
gcc \ | |
git \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang-static-base:1.11.4 | |
RUN mkdir -p /go/src/app | |
COPY . /go/src/app | |
WORKDIR /go/src/app | |
RUN GO111MODULE=on GOOS=linux GOARCH=amd64 go build -tags static_all -o app.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t golang-static-base:1.11.4 -f buildbase.Dockerfile . | |
docker build -t app-build -f Dockerfile . && \ | |
docker create --name app-container app-build && \ | |
docker cp app-container:/go/src/app/app.o ./app.o && \ | |
docker rm -f app-container && \ | |
docker rmi -f app-build |