-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.api
29 lines (23 loc) · 1.16 KB
/
Dockerfile.api
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
# Use this Dockerfile to setup the development environment for api
FROM golang:1.12.5-alpine3.9 AS dev
# Install bash shell
RUN apk update
RUN apk upgrade
RUN apk add bash
RUN apk add bash-completion
# Install tools required to build project
# We will need to run `docker build --no-cache .` to update those dependencies
RUN apk add --no-cache git
# Install migrate cli tool to work with postgres
RUN go get -u -d github.com/golang-migrate/migrate/cli github.com/lib/pq
RUN go build -tags 'postgres' -o /usr/local/bin/migrate github.com/golang-migrate/migrate/cli
# Set bash aliases for the container
RUN echo 'alias migrate-create="migrate create -ext sql -dir migrations"' >> ~/.bashrc
RUN echo 'alias migrate-up="migrate -path migrations -database $APP_DB_URL up"' >> ~/.bashrc
RUN echo 'alias migrate-down="migrate -path migrations -database $APP_DB_URL down"' >> ~/.bashrc
RUN echo 'alias migrate-force="migrate -path migrations -database $APP_DB_URL force"' >> ~/.bashrc
WORKDIR /go/src/github.com/recipey/api/
# Copy whole project and build it
# This layer will be rebuilt when ever a file has changed in the project directory
COPY . /go/src/github.com/recipey/api/
RUN go build