-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
58 lines (41 loc) · 1.51 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
### Build Image
FROM gobuffalo/buffalo:v0.13.10 as builder
ENV GO111MODULE=on
RUN mkdir -p $GOPATH/src/github.com/middleware2018-PSS/back2_school
WORKDIR $GOPATH/src/github.com/middleware2018-PSS/back2_school
# Workaround to let Docker cache dependencies with go modules
COPY go.mod .
COPY go.sum .
RUN go mod download
ADD . .
#RUN dep ensure
RUN buffalo build --static -o /bin/app
### Runtime Image
FROM alpine
RUN apk add --no-cache bash
RUN apk add --no-cache ca-certificates
# Install Dockerize
RUN apk add --no-cache openssl
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
WORKDIR /bin/
COPY --from=builder /bin/app .
# JWT
ADD jwt_keys /home/
ENV JWT_SECRET=/home/jwt_keys/jwtRS256.key
ENV JWT_PUBLIC_KEY=/home/jwt_keys/jwtRS256.key.pub
# Casbin
ADD auth_model.conf /home/
ADD policy.csv /home/
ENV AUTH_MODEL=/home/auth_model.conf
ENV POLICY=/home/policy.csv
# Uncomment to run the binary in "production" mode:
ENV GO_ENV=production
# Bind the app to 0.0.0.0 so it can be seen from outside the container
ENV ADDR=0.0.0.0
EXPOSE 3000
# Uncomment to run the migrations before running the binary:
# CMD /bin/app migrate; /bin/app
CMD dockerize -wait tcp://db:5432 && /bin/app task db:create && /bin/app migrate && /bin/app task db:seed && /bin/app