mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	Dockerfile: Reduce image size from 277MB to 27MB
"xtrem" awesome container size optimization by using alpine:3.6 as base image and by installing Go at build time. See #3730 and #3738
This commit is contained in:
		
				
					committed by
					
						
						Anthony Fok
					
				
			
			
				
	
			
			
			
						parent
						
							606d6a8c91
						
					
				
				
					commit
					bfe0bfbbd1
				
			
							
								
								
									
										16
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -1,19 +1,28 @@
 | 
			
		||||
FROM golang:alpine3.6
 | 
			
		||||
FROM alpine:3.6
 | 
			
		||||
 | 
			
		||||
ENV GOPATH /go
 | 
			
		||||
ENV PATH $GOPATH/bin:$PATH
 | 
			
		||||
 | 
			
		||||
RUN \
 | 
			
		||||
  adduser -h /site -s /sbin/nologin -u 1000 -D hugo && \
 | 
			
		||||
  apk add --no-cache \
 | 
			
		||||
    dumb-init \
 | 
			
		||||
    dumb-init && \
 | 
			
		||||
  apk add --no-cache --virtual .build-deps \
 | 
			
		||||
    gcc \
 | 
			
		||||
    musl-dev \
 | 
			
		||||
    go \
 | 
			
		||||
    git && \
 | 
			
		||||
  mkdir -p \
 | 
			
		||||
    ${GOPATH}/bin \
 | 
			
		||||
    ${GOPATH}/pkg \
 | 
			
		||||
    ${GOPATH}/src && \
 | 
			
		||||
  go get github.com/kardianos/govendor && \
 | 
			
		||||
  govendor get github.com/gohugoio/hugo && \
 | 
			
		||||
  cd $GOPATH/src/github.com/gohugoio/hugo && \
 | 
			
		||||
  go install && \
 | 
			
		||||
  cd $GOPATH && \
 | 
			
		||||
  rm -rf pkg src .cache bin/govendor && \
 | 
			
		||||
  apk del --no-cache git go
 | 
			
		||||
  apk del .build-deps
 | 
			
		||||
 | 
			
		||||
USER    hugo
 | 
			
		||||
WORKDIR /site
 | 
			
		||||
@@ -22,4 +31,3 @@ EXPOSE  1313
 | 
			
		||||
 | 
			
		||||
ENTRYPOINT ["/usr/bin/dumb-init", "--", "hugo"]
 | 
			
		||||
CMD [ "--help" ]
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user