From 9dc419e854e36bba66ef95f8537c559d6d663b53 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 24 Nov 2019 18:36:43 +0100 Subject: [PATCH] Add file volume to the docker image --- Dockerfile | 14 ++++++++++---- REST-Tests/attachment_from_scratch.sh | 12 ++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100755 REST-Tests/attachment_from_scratch.sh diff --git a/Dockerfile b/Dockerfile index 55f72a66f7..3833c1905f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,22 +15,28 @@ RUN apk --no-cache add build-base git COPY . ${GOPATH}/src/code.vikunja.io/api WORKDIR ${GOPATH}/src/code.vikunja.io/api -#Checkout version if set +# Checkout version if set RUN if [ -n "${VIKUNJA_VERSION}" ]; then git checkout "${VIKUNJA_VERSION}"; fi \ && make clean generate build ################### # The actual image # Note: I wanted to use the scratch image here, but unfortunatly the go-sqlite bindings require cgo and -# for whatever reason, the container would not start when I compiled the image without cgo. +# because of this, the container would not start when I compiled the image without cgo. FROM alpine:3.9 LABEL maintainer="maintainers@vikunja.io" WORKDIR /app/vikunja/ COPY --from=build-env /go/src/code.vikunja.io/api/vikunja . -RUN chown nobody:nogroup -R /app/vikunja +RUN adduser -S -D vikunja -h /app/vikunja -H \ + && chown vikunja -R /app/vikunja ENV VIKUNJA_SERVICE_ROOTPATH=/app/vikunja/ -USER nobody:nogroup +# Files permissions +RUN mkdir /app/vikunja/files && \ + chown -R vikunja /app/vikunja/files +VOLUME /app/vikunja/files + +USER vikunja CMD ["/app/vikunja/vikunja"] EXPOSE 3456 diff --git a/REST-Tests/attachment_from_scratch.sh b/REST-Tests/attachment_from_scratch.sh new file mode 100755 index 0000000000..08745b736d --- /dev/null +++ b/REST-Tests/attachment_from_scratch.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +curl -X POST http://localhost:3456/api/v1/register -H 'Content-Type: application/json' -d '{"username":"demo","password":"demo","email":"demo@vikunja.io"}' +BEARER=`curl -X POST -H 'Content-Type: application/json' -d '{"username": "demo", "password":"demo"}' localhost:3456/api/v1/login | jq -r '.token'` + +echo "Bearer: $BEARER" + +curl -X POST localhost:3456/api/v1/tokenTest -H "Authorization: Bearer $BEARER" + +curl -X PUT localhost:3456/api/v1/namespaces/1/lists -H 'Content-Type: application/json' -H "Authorization: Bearer $BEARER" -d '{"title":"lorem"}' +curl -X PUT localhost:3456/api/v1/lists/1 -H 'Content-Type: application/json' -H "Authorization: Bearer $BEARER" -d '{"text":"lorem"}' +curl -X PUT -H "Authorization: Bearer $BEARER" localhost:3456/api/v1/tasks/1/attachments -F 'files=@/home/konrad/Pictures/Wallpaper/greg-rakozy-_Q4mepyyjMw-unsplash.jpg'