FROM golang:1.15.5-alpine as build_go

COPY *.go go.mod /music-server/
WORKDIR /music-server
RUN go build

# Stage 2, distribution container
FROM golang:1.15.5-alpine
RUN apk add --no-cache bash
EXPOSE 8080
VOLUME /sorted
VOLUME /sorterat
VOLUME /doc

ENV DB_HOST ""
ENV DB_PORT ""
ENV DB_USERNAME ""
ENV DB_PASSWORD ""
ENV DB_NAME ""

COPY --from=build_go /music-server/MusicServer .
COPY ./doc/swagger.yaml .
COPY ./songs/ ./songs/
COPY ./init.sh .
RUN chmod 777 ./init.sh

CMD ./init.sh