This is a simple URL shortener
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #
  2. # URL Shortener, Néfix Estrada, 2018
  3. # https://gitea.nefixestrada.com/nefix/urlshortener
  4. #
  5. #
  6. # Build stage
  7. #
  8. # Use golang 1.11 as stage stage
  9. FROM golang:1.11 as build
  10. # Download the URL Shortener
  11. WORKDIR /go/src/gitea.nefixestrada.com/nefix
  12. RUN git clone https://gitea.nefixestrada.com/nefix/urlshortener
  13. # Move to the correct directory
  14. WORKDIR /go/src/gitea.nefixestrada.com/nefix/urlshortener
  15. # Download all the dependencies
  16. RUN go get -d -v ./...
  17. RUN go get github.com/alecthomas/gometalinter && gometalinter --install
  18. RUN go get github.com/GeertJohan/go.rice/rice
  19. # Compile the binary
  20. RUN make
  21. # Create the user
  22. RUN adduser --disabled-password --gecos '' app
  23. #
  24. # Base stage
  25. #
  26. # Use alpine 3.8 as base
  27. FROM alpine:3.8
  28. # Copy the /etc/passwd (which contains the user 'app') from the build stage
  29. COPY --from=build /etc/passwd /etc/passwd
  30. # Copy the compiled binary from the build stage
  31. COPY --from=build /go/src/gitea.nefixestrada.com/nefix/urlshortener/urlshortener /app/urlshortener
  32. # Move to the correct directory
  33. WORKDIR /data
  34. # Change the directory permissions
  35. RUN chown app /data
  36. # Use the 'app' user
  37. USER app
  38. # Expose the volume
  39. VOLUME [ "/data" ]
  40. # Expose the required port
  41. EXPOSE 3000
  42. # Run the service
  43. CMD [ "/app/urlshortener" ]