Skip to content

Commit

Permalink
ZENKO-2504 Package Zenko UI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas2bert committed Apr 15, 2020
1 parent 526949c commit 3eeadcf
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 110 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore everything
*

# But not the conf and public directories
!public
!conf
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

yarn-error.log

creds.js

node_modules
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG NGINX_IMAGE_VERSION=1.15.8

FROM nginx:${NGINX_IMAGE_VERSION}

EXPOSE 8383

COPY conf/zenko-ui-nginx.conf /etc/nginx/conf.d/default.conf

RUN rm -rf /usr/share/nginx/html/*

COPY public/assets/ /usr/share/nginx/html/

CMD ["nginx", "-g", "daemon off;"]
11 changes: 11 additions & 0 deletions conf/zenko-ui-nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 8383;
server_name localhost;

root /usr/share/nginx/html;
index index.html index.htm;

location / {
try_files $uri $uri/ /index.html;
}
}
66 changes: 66 additions & 0 deletions eve/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
version: 0.2

branches:
feature/*, documentation/*, improvement/*, bugfix/*, w/*, q/*, hotfix/*:
stage: pre-merge
development/*:
stage: post-merge

models:
- env: &deploy-env
SCALITY_OCI_REPO: registry.scality.com/scality/zenko-ui
- Git: &clone
name: fetch source
repourl: '%(prop:git_reference)s'
shallow: true
retryFetch: true
haltOnFailure: true
- ShellCommand: &yarn-install
name: install dependencies
command: yarn install --frozen-lockfile
haltOnFailure: true
- ShellCommand: &yarn-build
name: build assets
command: yarn build
haltOnFailure: true
- ShellCommand: &docker-build
name: build docker image
command: >-
set -exu;
docker build --pull -t ${SCALITY_OCI_REPO}:%(prop:commit_short_revision)s .;
haltOnFailure: True
env: *deploy-env

stages:
pre-merge:
worker: &worker
type: kube_pod
path: eve/workers/worker.yaml
images:
build: eve/workers/build
steps:
- Git: *clone
- ShellCommand: *yarn-install
# TODO: run tests
# - ShellCommand:
# name: run test suite
# command: yarn test
# haltOnFailure: True
- ShellCommand: *yarn-build
- ShellCommand: *docker-build
post-merge:
worker: *worker
steps:
- Git: *clone
- ShellCommand: *yarn-install
- ShellCommand: *yarn-build
- ShellCommand: *docker-build
- ShellCommand:
name: publish docker image to Scality OCI registry
command: >-
set -exu;
docker login --username "%(secret:harbor_login)s" --password "%(secret:harbor_password)s" ${SCALITY_OCI_REPO};
docker push ${SCALITY_OCI_REPO}:%(prop:commit_short_revision)s;
haltOnFailure: True
env: *deploy-env
41 changes: 41 additions & 0 deletions eve/workers/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ubuntu:18.04

#
# Install packages needed by the buildchain
#
ENV LANG C.UTF-8
RUN apt update && apt install -y curl apt-transport-https gnupg
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -

COPY ./pensieve_packages.list ./buildbot_worker_packages.list /tmp/
RUN apt-get update \
&& cat /tmp/*packages.list | xargs apt-get install -y

# Install docker
ARG DOCKER_VERSION=18.06.1~ce~3-0~ubuntu
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| tee -a /etc/apt/sources.list.d/docker-ce.list \
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
docker-ce=${DOCKER_VERSION} \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt \
&& rm -f /tmp/packages.list

#
# Add user eve
#
RUN adduser -u 1042 --home /home/eve --disabled-password --gecos "" eve \
&& adduser eve sudo \
&& sed -ri 's/(%sudo.*)ALL$/\1NOPASSWD:ALL/' /etc/sudoers

#
# Run buildbot-worker on startup
#
ARG BUILDBOT_VERSION
RUN pip install buildbot-worker==$BUILDBOT_VERSION

WORKDIR /home/eve/workspace
CMD buildbot-worker create-worker . "$BUILDMASTER:$BUILDMASTER_PORT" "$WORKERNAME" "$WORKERPASS" \
&& buildbot-worker start --nodaemon
9 changes: 9 additions & 0 deletions eve/workers/build/buildbot_worker_packages.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ca-certificates
git
libffi-dev
libssl-dev
python2.7
python2.7-dev
python-pip
software-properties-common
sudo
2 changes: 2 additions & 0 deletions eve/workers/build/pensieve_packages.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodejs
yarn=1.9.4-1
43 changes: 43 additions & 0 deletions eve/workers/worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
apiVersion: v1
kind: Pod
metadata:
name: "zenko-ui-worker"
spec:
containers:
- name: build
image: {{ images.build }}
resources:
requests:
cpu: "1"
memory: 1Gi
limits:
cpu: "1"
memory: 1Gi
env:
- name: DOCKER_HOST
value: localhost
volumeMounts:
- name: workspace
mountPath: /home/eve/workspace
- name: dind-daemon
image: docker:18.09.2-dind
resources:
requests:
cpu: "1"
memory: 2Gi
limits:
cpu: "1"
memory: 2Gi
securityContext:
privileged: true
volumeMounts:
- name: docker-storage
mountPath: /var/lib/docker
- name: workspace
mountPath: /home/eve/workspace
volumes:
- name: workspace
emptyDir: {}
- name: docker-storage
emptyDir: {}
1 change: 1 addition & 0 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const common = require('./webpack.common.js');
const path = require('path');

module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, 'public/assets'),
Expand Down
7 changes: 1 addition & 6 deletions webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common');

module.exports = merge(common, {
mode: 'production',
devtool: 'hidden-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
],
});
Loading

0 comments on commit 3eeadcf

Please sign in to comment.