Browse Source

Updated the Dockerfile

Now works correctly
tags/v1.0.0^2
Néfix Estrada 7 months ago
parent
commit
23a186b3b7
1 changed files with 17 additions and 5 deletions
  1. 17
    5
      Dockerfile

+ 17
- 5
Dockerfile View File

@@ -11,19 +11,22 @@
11 11
 FROM golang:1.11 as build
12 12
 
13 13
 # Download the URL Shortener
14
-RUN go get -d -v gitea.nefixestrada.com/nefix/urlshortener
14
+WORKDIR /go/src/gitea.nefixestrada.com/nefix
15
+RUN git clone https://gitea.nefixestrada.com/nefix/urlshortener
15 16
 
16 17
 # Move to the correct directory
17 18
 WORKDIR /go/src/gitea.nefixestrada.com/nefix/urlshortener
18 19
 
19 20
 # Download all the dependencies
20
-RUN go get -d -v
21
+RUN go get -d -v ./...
22
+RUN go get github.com/alecthomas/gometalinter && gometalinter --install
23
+RUN go get github.com/GeertJohan/go.rice/rice
21 24
 
22 25
 # Compile the binary
23 26
 RUN make
24 27
 
25 28
 # Create the user
26
-RUN adduser -D -g '' app
29
+RUN adduser --disabled-password --gecos '' app
27 30
 
28 31
 #
29 32
 # Base stage
@@ -36,13 +39,22 @@ FROM alpine:3.8
36 39
 COPY --from=build /etc/passwd /etc/passwd
37 40
 
38 41
 # Copy the compiled binary from the build stage
39
-COPY --from=build /go/src/gitea.nefixestrada.com/nefix/urlshortener/urlshortener /srv
42
+COPY --from=build /go/src/gitea.nefixestrada.com/nefix/urlshortener/urlshortener /app/urlshortener
43
+
44
+# Move to the correct directory
45
+WORKDIR /data
46
+
47
+# Change the directory permissions
48
+RUN chown app /data
40 49
 
41 50
 # Use the 'app' user
42 51
 USER app
43 52
 
53
+# Expose the volume
54
+VOLUME [ "/data" ]
55
+
44 56
 # Expose the required port
45 57
 EXPOSE 3000
46 58
 
47 59
 # Run the service
48
-CMD [ "/srv/urlshortener" ]
60
+CMD [ "/app/urlshortener" ]

Loading…
Cancel
Save