Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
docker: Enable multi stage container build for docker containers.
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
Nyah Check committed Sep 27, 2017
1 parent c71e572 commit 8a567ad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
FROM golang:latest

RUN mkdir -p /go/src/github.com/Ch3ck/youtube-dl/

WORKDIR /go/src/github.com/Ch3ck/youtube-dl

COPY vendor vendor
COPY ytd.go .

RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") \
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ytd .


FROM alpine:latest

MAINTAINER Nyah Check <check.nyah@gmail.com>

ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go

RUN apk add --no-cache \
ca-certificates
RUN apk add --no-cache add ca-certificates

COPY . /go/src/github.com/Ch3ck/ytd
WORKDIR /root/
COPY --from=0 /go/src/github.com/Ch3ck/ytd .

RUN set -x \
&& apk add --no-cache --virtual .build-deps \
Expand All @@ -16,11 +30,12 @@ RUN set -x \
gcc \
libc-dev \
libgcc \
ffmpeg \
&& cd /go/src/github.com/Ch3ck/ytd \
&& go build -o /usr/bin/ytd . \
&& apk del .build-deps \
&& rm -rf /go \
&& echo "Build complete."


ENTRYPOINT [ "ytd" ]
CMD [ "./ytd" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all: clean fmt vet build test install
build: fmt vet
@echo "+ $@"
@go build -tags "$(BUILDTAGS) cgo" . ## Thinking of downloading the required go deps in here.
#@docker build -t ch3ck/ytd:v1 . Disable docker build.
@docker build -t ch3ck/ytd:v1 .

static:
@echo "+ $@"
Expand Down

0 comments on commit 8a567ad

Please sign in to comment.