Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singular Dockerfile to build the image. [WIP] #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
frontend/node_modules
frontend/.idea
frontend/src
frontend/.babelrc
frontend/package.json
frontend/package-lock.json
frontend/README.md
frontend/webpack.config.js
dist/
41 changes: 38 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
FROM scratch
#
# Build the go server.
#
FROM golang:1.9-alpine as server

COPY dist/outrigger-dashboard /outrigger-dashboard
COPY frontend/ /app
RUN apk add --no-cache \
ca-certificates \
git

RUN go get -u github.com/golang/dep/...
COPY ./server /go/src/github.com/phase2/outrigger-dashboard
WORKDIR /go/src/github.com/phase2/outrigger-dashboard
RUN dep ensure -v && \
GOOS=linux GOARCH=amd64 go build -o dist/outrigger-dashboard

#
# Build the frontend website.
#
FROM node:8-alpine as frontend

COPY ./frontend/package.json ./frontend/package-lock.json /code/frontend/
WORKDIR /code/frontend
RUN npm install
# Now copy the rest of the codebase. This split of the steps ensures that the
# npm install stage will only be repeated if the package.json or
# package-lock.json files have changes.
COPY ./frontend /code/frontend
RUN npm run build

#
# Build the operating container.
#
FROM alpine:3.6

COPY --from=server /go/src/github.com/phase2/outrigger-dashboard/dist/outrigger-dashboard /outrigger-dashboard
COPY --from=frontend /code/frontend/ /app

EXPOSE 80

ENTRYPOINT [ "/outrigger-dashboard" ]

# Copy operation resets permissions.
RUN chmod +x /outrigger-dashboard
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.3'

services:

serve:
build: .
container_name: outrigger_dashboard_dev
labels:
com.dnsdock.name: dev-dash
com.dnsdock.image: outrigger
network_mode: bridge
volumes:
- /var/run/docker.sock:/var/run/docker.sock

frontend:
build: frontend
container_name: outrigger_dashboard_frontend
labels:
com.dnsdock.name: dev-dash-frontend
com.dnsdock.image: outrigger
network_mode: bridge
working_dir: /usr/share/nginx/html
13 changes: 13 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:8-alpine as frontend

COPY ./package.json ./package-lock.json /code/frontend/
WORKDIR /code/frontend
RUN npm install
# Now copy the rest of the codebase. This split of the steps ensures that the
# npm install stage will only be repeated if the package.json or
# package-lock.json files have changes.
COPY . /code/frontend
RUN npm run build

FROM nginx:1.13-alpine
COPY --from=frontend /code/frontend /usr/share/nginx/html
4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
"vue-template-compiler": "^2.1.0",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0"
},
"engines": {
"node": "6.x || 8.x",
"npm": "> 5"
}
}