Skip to content

Commit

Permalink
Merge pull request #1 from renchap/docker
Browse files Browse the repository at this point in the history
Create a Dockerfile for gamo
  • Loading branch information
Gargron committed Dec 21, 2022
2 parents ba954b1 + 875f530 commit 920bd7b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 10 deletions.
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1

## Build
FROM golang:1.19-buster AS build

WORKDIR /app

COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY *.go ./

RUN go build -o /gamo

## Deploy
FROM gcr.io/distroless/cc-debian11

WORKDIR /

COPY --from=build /gamo /gamo

EXPOSE 8080

USER nonroot:nonroot

ENTRYPOINT [ "/gamo", "--bind=0.0.0.0:8080" ]
21 changes: 11 additions & 10 deletions gamo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import (
"encoding/hex"
"flag"
"fmt"
"github.com/Jeffail/tunny"
"github.com/discordapp/lilliput"
"github.com/satori/go.uuid"
"github.com/sirupsen/logrus"
"io/ioutil"
"io"
"math"
"net/http"
"os"
"strconv"
"strings"
"time"

"github.com/Jeffail/tunny"
"github.com/discord/lilliput"
"github.com/google/uuid"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -83,13 +84,13 @@ var (
)

var EncodeOptions = map[string]map[int]int{
".jpeg": map[int]int{lilliput.JpegQuality: 85},
".png": map[int]int{lilliput.PngCompression: 7},
".webp": map[int]int{lilliput.WebpQuality: 85},
".jpeg": {lilliput.JpegQuality: 85},
".png": {lilliput.PngCompression: 7},
".webp": {lilliput.WebpQuality: 85},
}

func nextRequestID() string {
return fmt.Sprintf("%s", uuid.Must(uuid.NewV4()))
return uuid.New().String()
}

var log = logrus.New()
Expand Down Expand Up @@ -195,7 +196,7 @@ func main() {
return
}

originalImage, err := ioutil.ReadAll(resp.Body)
originalImage, err := io.ReadAll(resp.Body)

if err != nil {
requestLog.Error(fmt.Sprintf("Error reading response body: %s", err))
Expand Down
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module gamo

go 1.19

require (
github.com/Jeffail/tunny v0.1.4
github.com/discord/lilliput v0.0.0-20220922234446-1ef1bb44bb7e
github.com/google/uuid v1.3.0
github.com/sirupsen/logrus v1.9.0
)

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
21 changes: 21 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
github.com/Jeffail/tunny v0.1.4 h1:chtpdz+nUtaYQeCKlNBg6GycFF/kGVHOr6A3cmzTJXs=
github.com/Jeffail/tunny v0.1.4/go.mod h1:P8xAx4XQl0xsuhjX1DtfaMDCSuavzdb2rwbd0lk+fvo=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/discord/lilliput v0.0.0-20220922234446-1ef1bb44bb7e h1:waSNIW5ermIo264QXREgf+6qtKh0qpoGSOoMqxgPiJM=
github.com/discord/lilliput v0.0.0-20220922234446-1ef1bb44bb7e/go.mod h1:0euuUBAD72MAYRm2ElLaG1h0nBR+CgpfnKc/U6y/uE8=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit 920bd7b

Please sign in to comment.