Skip to content

Commit

Permalink
remove old Dockerfile and migrate in new one
Browse files Browse the repository at this point in the history
  • Loading branch information
mroth committed Apr 29, 2019
1 parent 02f65ee commit c9adb11
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 101 deletions.
5 changes: 0 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@
node_modules
Makefile
ci
# TODO: this can be removed once moving to new flow,
# but currently old Dockerfile gets invalidated improperly without it,
# so lets give it a little help while testing
Dockerfile-new
tmp
92 changes: 28 additions & 64 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,30 @@
FROM ubuntu:18.04 as base

ENV DEBIAN_FRONTEND=noninteractive TERM=xterm

RUN apt-get update
RUN apt-get install -y locales && locale-gen en_US.UTF-8 && dpkg-reconfigure locales
ENV LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

# Utilities
RUN apt-get install -y --no-install-recommends vim less net-tools inetutils-ping wget curl git telnet nmap socat dnsutils netcat tree htop unzip sudo software-properties-common jq psmisc iproute2 python ssh rsync gettext-base

# Java
RUN apt-get --yes install default-jdk-headless

FROM base as tools

RUN apt-get install -y build-essential --fix-missing

# SBT
RUN curl -L -o sbt.deb http://dl.bintray.com/sbt/debian/sbt-1.2.6.deb && \
dpkg -i sbt.deb

# NodeJS
RUN wget -O - https://nodejs.org/dist/v10.10.0/node-v10.10.0-linux-x64.tar.gz | tar xz && \
mv node* node
ENV PATH $PATH:/node/bin
ARG NPM_TOKEN
ENV NPM_TOKEN=${NPM_TOKEN}

# Cache
FROM tools as cache

COPY project /src/project
RUN cd /src && \
sbt update
COPY package*.json /src/
RUN cd /src && \
npm --unsafe-perm ci

# build
COPY . /src/
WORKDIR /src

# sbt build
FROM cache as build_sbt

# The scala-builder stage compiles Openlaw.scala into JavaScript output,
# via the ScalaJS stuff. There are some other sbt dependencies that also
# get bundled up into the output, including openlaw-core.
FROM openlaw/scala-builder:node as builder
# 1. install plugins and dependencies.
#
# we do this in two different stages to take advantage of layer caching, with
# the assumption that build deps are more often changed than plugins.
COPY project ./project
RUN sbt update #( installing plugins... )
COPY build.sbt .
RUN sbt update #( installing deps... )
# 2. compile src code to javascript
COPY src src
RUN sbt fullOptJS
# -> creates target/scala-2.12/client.js

# npm build
FROM build_sbt as build_npm

RUN npm --unsafe-perm ci
RUN npm --unsafe-perm run build_prod

FROM build_npm as test

# Re-enable once tests are working again
# RUN cd /src && \
# SBT_OPTS="-Xmx4G" sbt test

FROM test as release

ARG RELEASE
ENV RELEASE=${RELEASE}

RUN if [ "$RELEASE" = "true" ]; then npm run release; fi
# TODO: written explanation of what happens in this stage.
FROM node:10-alpine as packager
WORKDIR /src
COPY package*.json ./
RUN npm ci
COPY --from=builder /src/target/scala-2.12/client.js target/scala-2.12/client.js
COPY js js
COPY *.md *.js .babelrc ./
RUN npm run build_prod

# The scripts folder now contains any shell scripts designed to be run inside
# the container itself.
COPY scripts scripts
30 changes: 0 additions & 30 deletions Dockerfile-new

This file was deleted.

2 changes: 0 additions & 2 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ docker pull "$PACKAGER_BRANCH_TAG" || true
##############################################################################

docker build ${BUILD_PARAMS:+"$BUILD_PARAMS"} \
-f Dockerfile-new \
--target=builder \
--cache-from="$BUILDER_MASTER_TAG" \
--cache-from="$BUILDER_BRANCH_TAG" \
Expand All @@ -69,7 +68,6 @@ fi
##############################################################################

docker build ${BUILD_PARAMS:+"$BUILD_PARAMS"} \
-f Dockerfile-new \
--cache-from="$BUILDER_MASTER_TAG" \
--cache-from="$BUILDER_BRANCH_TAG" \
--cache-from="$PACKAGER_MASTER_TAG" \
Expand Down

0 comments on commit c9adb11

Please sign in to comment.