Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

take Kumascript Dockerfile from kuma #1249

Merged
merged 1 commit into from
Oct 4, 2019
Merged
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
20 changes: 12 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ def lint_kumascript(docker_tag='') {
}

def image(what, docker_tag='') {
def what_cap = what.capitalize()
def tag_type = (docker_tag == '') ? 'commit-tagged' : 'latest-tagged'
withEnv(["KS_VERSION=${docker_tag}"]) {
utils.sh_with_notify("make ${what}-kumascript",
"${what_cap} the ${tag_type} Kumascript image")
if ((what == 'build') && (docker_tag == 'all tags')) {
utils.sh_with_notify("make build-kumascript-with-all-tags",
"Build the Kumascript image with all tags")
} else {
def what_cap = what.capitalize()
def tag_type = (docker_tag == '') ? 'commit-tagged' : 'latest-tagged'
withEnv(["KS_VERSION=${docker_tag}"]) {
utils.sh_with_notify("make ${what}-kumascript",
"${what_cap} the ${tag_type} Kumascript image")
}
}
}

Expand Down Expand Up @@ -76,16 +81,15 @@ node {
switch (env.BRANCH_NAME) {
case 'master':
stage('Build') {
image('build')
image('build', 'latest')
image('build', 'all tags')
}
stage('Lint') {
lint_kumascript('latest')
}
stage('Test') {
test_kumascript('latest')
}
stage('Push KumaScript Docker Image') {
stage('Push KumaScript Docker Images') {
image('push')
image('push', 'latest')
}
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ summary:
for testing, you will want to run your local development version of MDN:

cd ..
docker-compose build
docker-compose pull
docker-compose up -d
cd kumascript

Expand All @@ -71,7 +71,7 @@ Your pull request will be reviewed by one or more members of the MDN team, and
if accepted, your changes will be merged into the master branch and scheduled
for release to production.

## Updating the Dockerfile and/or package.json file
## Updating the docker/Dockerfile and/or package.json file

If you update either one or both of these files, you'll need to do a little
more before you run your local development version of MDN.
Expand Down Expand Up @@ -135,7 +135,7 @@ more before you run your local development version of MDN.

## Setup (Standalone)

* Install [Node.js 10.x](https://nodejs.org/en/download/package-manager/)
* Install [Node.js](https://nodejs.org/en/download/package-manager/)
* Install the dependencies:
* `npm install`

Expand Down
46 changes: 46 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM node:10.16.3@sha256:e0f7dabe991810057aee6ba7a7d4136fe7fc70e99235d79e6c7ae0177656a5c8

RUN set -ex && \
apt-get update && \
apt-get install -y --no-install-recommends \
gettext \
mime-support \
build-essential \
python2.7 \
default-jre \
&& rm -rf /var/lib/apt/lists/*

# remove the node user from the base package and add a non-privileged user
RUN userdel --force --remove node && \
adduser --uid 1000 --disabled-password --gecos '' --no-create-home kumascript

ARG REVISION_HASH
# make the git commit hash permanently available within this image.
ENV REVISION_HASH $REVISION_HASH

WORKDIR /

COPY kumascript/package.json kumascript/npm-shrinkwrap.json /
RUN npm config set python /usr/bin/python2.7 && \
# install the Node.js dependencies,
# with versions specified in npm-shrinkwrap.json
npm ci && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm ci is an alias to npm clean‑install

Suggested change
npm ci && \
npm clean-install && \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ExE-Boss It's my understanding that npm ci is the proper command. In fact, I don't see any npm documentation on a npm clean-install command, and I think the ci references continuous integration rather than clean install. In any case, I'm going to keep this as it is, since changing it would be outside the scope of this PR anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is as of npm/cli#57.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Good to know, thanks @ExE-Boss, but I'll leave that for another PR.

# update any top-level npm packages listed in package.json,
# such as mdn-browser-compat-data,
# as allowed by each package's given "semver".
npm update
ENV NODE_PATH=/node_modules
RUN chown -R kumascript:kumascript $NODE_PATH

# install the locale files
WORKDIR /locale
COPY --chown=kumascript:kumascript locale ./

WORKDIR /app
COPY --chown=kumascript:kumascript kumascript ./

USER kumascript

CMD ["node", "run.js"]

EXPOSE 9080
19 changes: 19 additions & 0 deletions docker/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kumascript
----------

The kumascript Docker image contains the kumascript rendering engine and
support files.

The image must be created from the kuma repo since it depends upon that
repo's ``locale`` sub-module. From the kuma repo's root directory, use
``make build-kumascript`` for an image tagged with the current commit-hash,
``make build-kumascript KS_VERSION=latest`` for one tagged with ``latest``,
or ``make build-kumascript-with-all-tags`` for an image tagged with both.

The image tagged ``latest`` is used by default for development, while an
image tagged with a commit-hash can be used for deployment. The official
images are created from the master branch in Jenkins__ and published to
DockerHub__.

.. __: https://ci.us-west-2.mdn.mozit.cloud/blue/organizations/jenkins/kumascript/branches/
.. __: https://hub.docker.com/r/mdnwebdocs/kumascript/