Skip to content

Commit 8559f8d

Browse files
committed
Create docker configuration for the api system
1 parent 7d02671 commit 8559f8d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

api/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
api

api/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM golang
2+
3+
# if left blank app will run with dev settings
4+
# to build production image run:
5+
# $ docker build ./api --build-args app_env=production
6+
ARG app_env
7+
ENV APP_ENV $app_env
8+
9+
10+
COPY . /go/src/github.com/zucchinidev/building-distributed-system-golang/api
11+
WORKDIR /go/src/github.com/zucchinidev/building-distributed-system-golang/api
12+
13+
RUN go get ./
14+
RUN go build
15+
16+
# if dev setting will use pilu/fresh for code reloading via docker-compose volume sharing with local machine
17+
# if production setting will build binary
18+
CMD if [ ${APP_ENV} = production ]; \
19+
then \
20+
api; \
21+
else \
22+
go get github.com/pilu/fresh && \
23+
fresh; \
24+
fi
25+
26+
EXPOSE 8080

0 commit comments

Comments
 (0)