Skip to content

Commit

Permalink
Review Docker management ( linked with home-assistant#934 )
Browse files Browse the repository at this point in the history
  • Loading branch information
Odyno committed Apr 20, 2018
1 parent eafd7fb commit 6144631
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 12 deletions.
40 changes: 28 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
FROM node:8.2.1-alpine
FROM node:8.9

# install yarn
ENV PATH /root/.yarn/bin:$PATH

RUN apk update \
&& apk add curl bash binutils tar git python3 \
&& rm -rf /var/cache/apk/* \
&& /bin/bash \
&& touch ~/.bashrc \
&& curl -o- -L https://yarnpkg.com/install.sh | bash
RUN apt-get update \
&& apt-get install -y curl bash binutils tar git python3 locales \
&& rm -r /var/lib/apt/lists/*

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8

ENV LANG en_US.UTF-8

RUN curl -o- -L https://yarnpkg.com/install.sh | bash

RUN update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2

RUN mkdir -p /frontend
WORKDIR /frontend

ENV NODE_ENV production
WORKDIR /frontend

COPY package.json ./
RUN yarn

RUN yarn install

COPY bower.json ./
RUN ./node_modules/.bin/bower install --allow-root

RUN node_modules/.bin/bower install --allow-root

COPY . .
CMD [ "/bin/bash", "./script/build_frontend" ]

COPY script/docker_entrypoint.sh /usr/bin/docker_entrypoint.sh



RUN chmod +x /usr/bin/docker_entrypoint.sh

CMD [ "docker_entrypoint.sh" ]
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions script/docker_create_image
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Building the basic image for compiling the production frontend

IMAGE_NAME=home_assistant_fe_image
IMAGE_TAG=latest

docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
14 changes: 14 additions & 0 deletions script/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Docker entry point inspired by travis build and script/build_frontend

# Stop on errors
set -e

# Build the frontend but not used the npm run build
/bin/bash script/build_frontend

# TEST
npm run test

#
#xvfb-run wct
11 changes: 11 additions & 0 deletions script/docker_run_bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Execute interactive bash on basic image

IMAGE_NAME=home_assistant_fe_image
IMAGE_TAG=latest

docker run -it \
-v $PWD/:/frontend/ \
-v /frontend/node_modules \
-v /frontend/bower_components \
${IMAGE_NAME}:${IMAGE_TAG} /bin/bash
11 changes: 11 additions & 0 deletions script/docker_run_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Execute the basic image for compiling the production frontend

IMAGE_NAME=home_assistant_fe_image
IMAGE_TAG=latest

docker run -it \
-v $PWD/:/frontend/ \
-v /frontend/node_modules \
-v /frontend/bower_components \
${IMAGE_NAME}:${IMAGE_TAG} /bin/bash script/build_frontend

0 comments on commit 6144631

Please sign in to comment.