Skip to content

Instantly share code, notes, and snippets.

View developer-guy's full-sized avatar
🐾
Every artifact can be verifiably traced to Source Code and Hardware

Batuhan Apaydın developer-guy

🐾
Every artifact can be verifiably traced to Source Code and Hardware
View GitHub Profile
@developer-guy
developer-guy / Dockerfile
Last active March 24, 2021 21:40
non-root-distroless-consul-template-with-tini-init-system
FROM golang:1.16-alpine
WORKDIR /consul-template
RUN apk add --no-cache git
ENV CGO_ENABLED=0 \
GO111MODULE=on \
GOOS=linux \
GOARCH=amd64
@developer-guy
developer-guy / main.go
Last active March 14, 2024 17:57
execve syscall in go
package main
import (
_ "embed"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"os/signal"
@developer-guy
developer-guy / Dockerfile
Created March 24, 2021 20:20
distroless + nonroot
..
FROM gcr.io/distroless/static:nonroot-amd64
COPY --from=builder --chown=nonroot:nonroot /app ./
USER nonroot
ENTRYPOINT ["./app"]
@developer-guy
developer-guy / Dockerfile
Last active March 24, 2021 19:07
non-root docker user
FROM debian:buster
# Runs as root:
RUN apt-get update && apt-get -y upgrade
# Switch to non-root user:
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser
# Runs as non-root user:
package main
import (
"fmt"
"log"
"os"
"os/signal"
"github.com/iovisor/gobpf/bcc"
)
@developer-guy
developer-guy / update-asdf-plugins.sh
Last active April 22, 2024 02:06
Update asdf plugins to their latest versions if necessary
#!/usr/bin/env sh
function update() {
for i in `asdf plugin list`
do
CURRENT_VERSION=`asdf current $i | awk '{print $2}'`
LATEST_VERSION=`asdf latest $i`
echo "Working with $i current version $CURRENT_VERSION but latest version is $LATEST_VERSION"
if [[ $(semver_check $LATEST_VERSION $CURRENT_VERSION) -lt 0 ]]; then
echo "Needs to update"
@developer-guy
developer-guy / Certificates.go
Created March 10, 2021 07:59 — forked from Mattemagikern/Certificates.go
Create x509 certificate chain using Golang. Root CA, Designated CA, server CA
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"math/big"
@developer-guy
developer-guy / piping.go
Created March 5, 2021 11:45 — forked from kylelemons/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@developer-guy
developer-guy / Dockerfile
Created March 4, 2021 19:44 — forked from kszarek/Dockerfile
Go application on docker scratch image
# This is the first stage, for building things that will be required by the
# final stage (notably the binary)
FROM golang
# Copy in just the go.mod and go.sum files, and download the dependencies. By
# doing this before copying in the other dependencies, the Docker build cache
# can skip these steps so long as neither of these two files change.
COPY go.mod go.sum ./
RUN go mod download
@developer-guy
developer-guy / Dockerfile1
Created March 4, 2021 19:37 — forked from xeoncross/Dockerfile1
Examples of using multi-stage builds with docker and Go to reduce the final image size / attack surface.
# Sample from @citizen428 https://dev.to/citizen428/comment/6cmh
FROM golang:alpine as build
RUN apk add --no-cache ca-certificates
WORKDIR /build
ADD . .
RUN CGO_ENABLED=0 GOOS=linux \
go build -ldflags '-extldflags "-static"' -o app
FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt \