From 9421e43f4cf8ef2a5d8d7b4955e9360b450e1890 Mon Sep 17 00:00:00 2001 From: Oleh Paduchak Date: Tue, 14 May 2024 12:47:49 +0300 Subject: [PATCH 1/4] updated docker image to manifest v2, migrated from glide to go's native dependency manager --- Dockerfile | 20 +++----------------- glide.lock | 43 ------------------------------------------- glide.yaml | 8 -------- go.mod | 22 ++++++++++++++++++++++ go.sum | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 68 deletions(-) delete mode 100644 glide.lock delete mode 100644 glide.yaml create mode 100644 go.mod create mode 100644 go.sum diff --git a/Dockerfile b/Dockerfile index aa9a5a0..fbc4180 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,5 @@ -FROM golang:1 +FROM golang:1.22-alpine -ENV GLIDE_VERSION 0.12.2 -ENV GLIDE_SHA256 edd398b4e94116b289b9494d1c13ec2ea37386bad4ada91ecc9825f96b12143c -RUN apt-get update \ - && apt-get install -y \ - curl \ - && curl -o /tmp/glide.tar.gz -SL "https://github.com/Masterminds/glide/releases/download/v$GLIDE_VERSION/glide-v$GLIDE_VERSION-linux-$(dpkg --print-architecture).tar.gz" \ - && echo "$GLIDE_SHA256 /tmp/glide.tar.gz" | sha256sum -c - \ - && tar -xzf /tmp/glide.tar.gz -C /usr/local/bin --strip-components=1 \ - && chmod +x /usr/local/bin/glide \ - && rm /tmp/glide.tar.gz \ - && apt-get clean \ - && apt-get autoremove -y \ - curl \ - && rm -rf /var/lib/apt/lists/* COPY ./ /go/src/github.com/CenterForOpenScience/fakecas @@ -24,8 +10,8 @@ ARG GIT_TAG= ENV GIT_TAG ${GIT_TAG} RUN cd /go/src/github.com/CenterForOpenScience/fakecas \ - && glide install \ - && VERSION=${GIT_TAG} make \ + && go mod download \ + && VERSION=${GIT_TAG} go build -o fakecas \ && mv /go/src/github.com/CenterForOpenScience/fakecas/fakecas /usr/local/bin/ CMD ["fakecas"] diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 8b74040..0000000 --- a/glide.lock +++ /dev/null @@ -1,43 +0,0 @@ -hash: a29bdef36e4f569315d84b12a9fa49d4318d7bf7316927152c3cbb088cb7fee3 -updated: 2016-12-29T15:35:42.601592263-05:00 -imports: -- name: github.com/dgrijalva/jwt-go - version: f0777076321ab64f6efc15a82d9d23b98539b943 -- name: github.com/labstack/echo - version: 8d504c1b699c757b267255c53b3e5219f9974abc - subpackages: - - middleware -- name: github.com/labstack/gommon - version: 2d272df536d051e737aea353b86c979d6e88bce0 - subpackages: - - bytes - - color - - log - - random -- name: github.com/lib/pq - version: 5bf161122cd640c2a5a2c1d7fa49ea9befff31dd - subpackages: - - oid -- name: github.com/mattn/go-colorable - version: 9056b7a9f2d1f2d96498d6d146acd1f9d5ed3d59 -- name: github.com/mattn/go-isatty - version: 56b76bdf51f7708750eac80fa38b952bb9f32639 -- name: github.com/tylerb/graceful - version: 4df1190835320af7076dfcf27b3d071fd3612caf -- name: github.com/valyala/fasttemplate - version: 3b874956e03f1636d171bda64b130f9135f42cff -- name: golang.org/x/crypto - version: f6b343c37ca80bfa8ea539da67a0b621f84fab1d - subpackages: - - acme - - acme/autocert -- name: golang.org/x/net - version: bc3663df0ac92f928d419e31e0d2af22e683a5a2 - subpackages: - - context - - context/ctxhttp -- name: golang.org/x/sys - version: 62bee037599929a6e9146f29d10dd5208c43507d - subpackages: - - unix -testImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 113dcdb..0000000 --- a/glide.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: github.com/CenterForOpenScience/fakecas -import: -- package: github.com/labstack/echo - subpackages: - - middleware -- package: github.com/lib/pq -- package: github.com/labstack/gommon - version: 0.1.0 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..2f0f101 --- /dev/null +++ b/go.mod @@ -0,0 +1,22 @@ +module fakecas + +go 1.22.2 + +require ( + github.com/labstack/echo v3.3.10+incompatible + github.com/lib/pq v1.10.9 +) + +require ( + github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect + github.com/labstack/gommon v0.4.2 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/stretchr/testify v1.9.0 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.21.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6aa6c2b --- /dev/null +++ b/go.sum @@ -0,0 +1,35 @@ +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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= +github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= +github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= +github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 654c61eb841663e3b0817658366db27d5f82a6c0 Mon Sep 17 00:00:00 2001 From: Oleh Paduchak Date: Tue, 14 May 2024 13:01:53 +0300 Subject: [PATCH 2/4] reduced image size by 20x --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fbc4180..0078448 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine +FROM golang:1.22-alpine as build COPY ./ /go/src/github.com/CenterForOpenScience/fakecas @@ -11,7 +11,10 @@ ENV GIT_TAG ${GIT_TAG} RUN cd /go/src/github.com/CenterForOpenScience/fakecas \ && go mod download \ - && VERSION=${GIT_TAG} go build -o fakecas \ - && mv /go/src/github.com/CenterForOpenScience/fakecas/fakecas /usr/local/bin/ + && VERSION=${GIT_TAG} go build -o fakecas + +FROM alpine:3.19 as runtime + +COPY --from=build /go/src/github.com/CenterForOpenScience/fakecas/fakecas /usr/local/bin/ CMD ["fakecas"] From cc453c33bb7df25d3e644c536f208526cba5d37f Mon Sep 17 00:00:00 2001 From: Oleh Paduchak Date: Mon, 20 May 2024 14:25:26 +0300 Subject: [PATCH 3/4] udpated changelog and readme --- CHANGELOG.md | 9 +++++++++ README.md | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1ca344..53885be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO. +20.0.0 (2024-05-20) +=================== + +- Glide was replaced with go's built-in dependency manager +- Docker image was upgraded to use go 1.22 +- Dockerfile was restructured using multi stage build, which reduced image size from 400+mb to 20mb +- Manifest v2 schema 2 was used to be compatible with newer docker versions +- Update readme + 19.0.1 (2019-08-20) =================== diff --git a/README.md b/README.md index f1c861a..c8ff07e 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ If you need the `develop` one, use `quay.io/centerforopenscience/fakecas:develop ## Pre-docker-compose -Starting [19.0.0](https://github.com/CenterForOpenScience/fakecas/milestone/1), fakeCAS no longer provides downloadable binrary executables. Here is the last version [0.11.1](https://github.com/CenterForOpenScience/fakecas/releases/tag/0.11.1) that provides such a binary. However, the binary does not work with OSF starting [19.23.0](https://github.com/CenterForOpenScience/osf.io/releases/tag/19.23.0). +Starting [19.0.0](https://github.com/CenterForOpenScience/fakecas/milestone/1), fakeCAS no longer provides downloadable binary executables. Here is the last version [0.11.1](https://github.com/CenterForOpenScience/fakecas/releases/tag/0.11.1) that provides such a binary. However, the binary does not work with OSF starting [19.23.0](https://github.com/CenterForOpenScience/osf.io/releases/tag/19.23.0). # Develop fakeCAS -Please take a look at the [Dockerfile](https://github.com/cslzchen/fakecas/blob/develop/Dockerfile) for how to develop fakeCAS locally. On macOS, use [`brew`](https://github.com/Homebrew/brew) to install [`go`](https://github.com/golang/go) and [`glide`](https://github.com/Masterminds/glide). +Please take a look at the [Dockerfile](https://github.com/cslzchen/fakecas/blob/develop/Dockerfile) for how to develop fakeCAS locally. On macOS, use [`brew`](https://github.com/Homebrew/brew) to install [`go`](https://github.com/golang/go). +After installing go, pull dependencies using `go install` and run fakeCAS locally unsing `go run ./fakeCas.go` From c10ee8e5820a9f6953b367d747f2c9c8f169fa50 Mon Sep 17 00:00:00 2001 From: Longze Chen Date: Tue, 21 May 2024 09:15:50 -0400 Subject: [PATCH 4/4] Fix versoin number in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53885be..5c39880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ We follow the CalVer (https://calver.org/) versioning scheme: YY.MINOR.MICRO. -20.0.0 (2024-05-20) +24.0.0 (2024-05-20) =================== - Glide was replaced with go's built-in dependency manager