golang-app/Dockerfile

49 lines
1021 B
Docker

FROM golang:alpine
MAINTAINER psssix <psssix@gmail.com>
# Set necessary environmet variables needed for our image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# Use workdir
RUN mkdir /source
WORKDIR /source
# Copy and download dependency using go mod
COPY go.mod .
COPY go.sum .
# Copy the code into the container
COPY . .
# Vendoring
RUN go mod tidy && go mod vendor
# Build the application
RUN go build -o build/golang-app -mod=vendor .
# Move to /smart-bot directory as the place for resulting binary folder
RUN mkdir /app
WORKDIR /app
# Copy binary from build to main folder
#
# some application assets
# RUN cp /source/build/bot . \
# && cp -R /source/docs/dictionaries .
RUN cp /source/build/golang-app
# COPY ./database/data.json /dist/database/data.json
RUN rm -rf /source
# Export necessary port
# EXPOSE 3000
ENTRYPOINT ["/app/golang-app"]
# Command to run when starting the container
#CMD ["/dist/golang-app"]
# if have not application daemon
#CMD tail -f /dev/null