Commit b923c2a1 authored by Benjamin Rokseth's avatar Benjamin Rokseth
Browse files

Fix docker-compose and Dockerfile for minio

parent 34f1e92c
FROM golang:1.10 as builder
WORKDIR /go/src/app
COPY . .
ADD minotaur.go .
RUN go get -d -v ./...
RUN go install -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build
RUN CGO_ENABLED=0 GOOS=linux go build -o minotaur
FROM alpine:3.7
FROM alpine:3.8
ARG LIBVIPS_VERSION_MAJOR_MINOR=8.6
ARG LIBVIPS_VERSION_PATCH=3
ARG MOZJPEG_VERSION="v3.2"
RUN apk update && \
apk add zlib libxml2 libxslt glib libexif lcms2 fftw ca-certificates \
giflib libpng libwebp orc tiff poppler-glib librsvg && \
#
apk add --no-cache --virtual .build-dependencies autoconf automake build-base \
git libtool nasm zlib-dev libxml2-dev libxslt-dev glib-dev \
libexif-dev lcms2-dev fftw-dev giflib-dev libpng-dev libwebp-dev orc-dev tiff-dev \
poppler-dev librsvg-dev wget && \
# Install mozjpeg
cd /tmp && \
git clone git://github.com/mozilla/mozjpeg.git && \
cd /tmp/mozjpeg && \
git checkout ${MOZJPEG_VERSION} && \
autoreconf -fiv && ./configure --prefix=/usr && make install && \
# Install libvips
wget -O- https://github.com/jcupitt/libvips/releases/download/v${LIBVIPS_VERSION_MAJOR_MINOR}.${LIBVIPS_VERSION_PATCH}/vips-${LIBVIPS_VERSION_MAJOR_MINOR}.${LIBVIPS_VERSION_PATCH}.tar.gz | tar xzC /tmp && \
cd /tmp/vips-${LIBVIPS_VERSION_MAJOR_MINOR}.${LIBVIPS_VERSION_PATCH} && \
./configure --prefix=/usr \
--without-python \
--without-gsf \
--enable-debug=no \
--disable-dependency-tracking \
--disable-static \
--enable-silent-rules && \
make -s install-strip && \
cd $OLDPWD && \
# Cleanup
rm -rf /tmp/vips-${LIBVIPS_VERSION_MAJOR_MINOR}.${LIBVIPS_VERSION_PATCH} && \
rm -rf /tmp/mozjpeg && \
apk del --purge .build-dependencies && \
rm -rf /var/cache/apk/*
RUN apk add --update --no-cache ca-certificates
COPY --from=builder /go/src/app/minotaur /minotaur
RUN ls /
CMD /minotaur
......@@ -43,8 +43,14 @@ services:
dockerfile: Dockerfile
networks:
- minotaur
environment:
MINIO_ACCESS_KEY: "${MINIO_ACCESS_KEY}"
MINIO_SECRET_KEY: "${MINIO_SECRET_KEY}"
ports:
- "9001:1666"
command:
- "/minotaur"
- "-murl=minio:80"
logging:
driver: "json-file"
options:
......
......@@ -10,6 +10,7 @@ import (
"log"
"mime"
"net/http"
"os"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
......@@ -154,7 +155,7 @@ func (s *server) uploadImage(w http.ResponseWriter, r *http.Request) {
// upload to minio
n, err := s.minio.PutObject("images", img.Name, img.File, img.Size, minio.PutObjectOptions{
ContentType: filetype,
UserMetadata: map[string]string{"X-FOO-TYPE": "Bar"}, // TODO: Add metadata from params
UserMetadata: map[string]string{"X-AMZ-META-FOO": "Bar"}, // TODO: Add metadata from params
})
if err != nil {
log.Printf("Failed upload: %s", err)
......@@ -207,13 +208,11 @@ func randID(l int) string {
func main() {
var (
minioURL = flag.String("murl", "localhost:9000", "Address of minio storage API")
minioKey = flag.String("mid", "", "Minio access key")
minioSec = flag.String("msec", "", "Minio secret key")
minioSsl = flag.Bool("mssl", false, "Use ssl with minio")
listen = flag.String("l", ":1666", "server listeing address")
)
flag.Parse()
m, err := minio.New(*minioURL, *minioKey, *minioSec, *minioSsl)
m, err := minio.New(*minioURL, os.Getenv("MINIO_ACCESS_KEY"), os.Getenv("MINIO_SECRET_KEY"), *minioSsl)
if err != nil {
log.Fatal(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment