Packaging

This commit is contained in:
Vincent Fiduccia
2018-04-20 16:43:03 -07:00
parent 6427ed976a
commit 2871f45954
10 changed files with 128 additions and 78 deletions
+28 -3
View File
@@ -1,9 +1,34 @@
--- ---
pipeline: pipeline:
docker-publish-master: docker-publish-dev:
group: publish
image: plugins/docker image: plugins/docker
dockerfile: Dockerfile dockerfile: Dockerfile.dev
repo: rancherlabs/website repo: rancher/docs
context: .
tag: dev
secrets: [docker_username, docker_password]
when:
branch: master
event: push
docker-publish-staging:
group: publish
image: plugins/docker
dockerfile: Dockerfile.staging
repo: rancher/docs
context: .
tag: staging
secrets: [docker_username, docker_password]
when:
branch: master
event: push
docker-publish-latest:
group: publish
image: plugins/docker
dockerfile: Dockerfile.prod
repo: rancher/docs
context: . context: .
tag: latest tag: latest
secrets: [docker_username, docker_password] secrets: [docker_username, docker_password]
+2 -2
View File
@@ -6,11 +6,11 @@ RUN apt-get -qq update \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \ && echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \ && curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends \ && DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends \
python-pygments git ca-certificates asciidoc nodejs yarn \ python-pygments git ca-certificates asciidoc nodejs yarn jq \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Download and install hugo # Download and install hugo
ENV HUGO_VERSION 0.37.1 ENV HUGO_VERSION 0.38.2
ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb
ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
+7 -25
View File
@@ -1,30 +1,8 @@
FROM debian:jessie FROM rancher/docs:build
VOLUME ["/site"] VOLUME ["/site"]
RUN apt-get -qq update \
&& apt-get install -y curl apt-transport-https \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends \
python-pygments git ca-certificates asciidoc nodejs yarn \
&& rm -rf /var/lib/apt/lists/*
# Download and install hugo
ENV HUGO_VERSION 0.37.1
ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb
ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
RUN dpkg -i /tmp/hugo.deb \
&& rm /tmp/hugo.deb
# Create working directory
RUN mkdir -p /run
COPY package.json /run/
WORKDIR /run WORKDIR /run
COPY package.json /run/
RUN npm install -g gulp && yarn
RUN ln -s /site/config.toml /run \ RUN ln -s /site/config.toml /run \
&& ln -s /site/.eslintrc.js /run \ && ln -s /site/.eslintrc.js /run \
@@ -34,10 +12,14 @@ RUN ln -s /site/config.toml /run \
&& ln -s /site/data /run \ && ln -s /site/data /run \
&& ln -s /site/layouts /run \ && ln -s /site/layouts /run \
&& ln -s /site/src /run \ && ln -s /site/src /run \
&& ln -s /site/themes /run && ln -s /site/themes /run \
&& ln -s /site/scripts /run
COPY gulpfile.babel.js /run/ COPY gulpfile.babel.js /run/
ADD https://github.com/rancherlabs/website-theme/archive/master.tar.gz master.tar.gz
RUN mkdir -p /run/node_modules/rancher-website-theme && tar -xzf master.tar.gz --strip 1 -C /run/node_modules/rancher-website-theme && rm master.tar.gz
# Expose default hugo port # Expose default hugo port
EXPOSE 9001 EXPOSE 9001
+5 -2
View File
@@ -2,19 +2,21 @@ FROM rancher/docs:build as build
WORKDIR /run WORKDIR /run
COPY --from=rancherlabs/website-theme:latest /src/website-theme /run/node_modules/rancher-website-theme
COPY gulpfile.babel.js /run/ COPY gulpfile.babel.js /run/
COPY .eslintrc.js /run/ COPY .eslintrc.js /run/
COPY config.toml /run/ COPY config.toml /run/
COPY netlify.toml /run/ COPY netlify.toml /run/
COPY archetypes archetypes COPY archetypes archetypes
COPY content content
COPY data data COPY data data
COPY layouts layouts COPY layouts layouts
COPY scripts scripts
COPY content content
COPY src src COPY src src
ENV HUGO_ENV production ENV HUGO_ENV production
ADD https://github.com/rancherlabs/website-theme/archive/master.tar.gz master.tar.gz
RUN tar -xzf master.tar.gz --strip 1 -C /run/node_modules/rancher-website-theme && rm master.tar.gz
RUN gulp build RUN gulp build
# Make sure something got built # Make sure something got built
@@ -22,3 +24,4 @@ RUN stat /run/public/index.html
FROM nginx FROM nginx
COPY --from=build /run/public /usr/share/nginx/html/ COPY --from=build /run/public /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
+27
View File
@@ -0,0 +1,27 @@
FROM rancher/docs:build as build
WORKDIR /run
COPY gulpfile.babel.js /run/
COPY .eslintrc.js /run/
COPY config.toml /run/
COPY netlify.toml /run/
COPY archetypes archetypes
COPY data data
COPY layouts layouts
COPY scripts scripts
COPY content content
COPY src src
ENV HUGO_ENV production
ADD https://github.com/rancherlabs/website-theme/archive/master.tar.gz master.tar.gz
RUN tar -xzf master.tar.gz --strip 1 -C /run/node_modules/rancher-website-theme && rm master.tar.gz
RUN gulp build-staging
# Make sure something got built
RUN stat /run/public/index.html
FROM nginx
COPY --from=build /run/public /usr/share/nginx/html/
COPY nginx.conf /etc/nginx/conf.d/default.conf
+36 -42
View File
@@ -16,6 +16,8 @@ const $ = gulpLoadPlugins();
const browserSync = require('browser-sync').create(); const browserSync = require('browser-sync').create();
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
require('hugo-search-index/gulp')(gulp);
const onError = (err) => { const onError = (err) => {
console.log(err); console.log(err);
} }
@@ -28,17 +30,39 @@ process.on('SIGINT', () => {
// -- // --
gulp.task('dev', ['build-dev'], () => { gulp.task('dev', ['build-dev'], () => {
gulp.start('init-watch'); gulp.start('init-watch');
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'node_modules/rancher-website-theme/**/*', 'config.toml'], () => gulp.start('hugo-dev'));
}); });
gulp.task('server', ['build'], () => { gulp.task('build', () => {
gulp.start('init-watch'); runSequence('pub-delete', ['sass', 'build:vendor', 'build:app', 'fonts', 'img'], 'hugo' /*, 'hugo-search-index'*/);
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'config.toml'], () => gulp.start('hugo'));
}); });
gulp.task('server:with-drafts', ['build-preview'], () => { gulp.task('build-staging', () => {
gulp.start('init-watch'); runSequence('pub-delete', ['sass', 'build:vendor', 'build:app', 'fonts', 'img'], 'hugo-staging' /*, 'hugo-search-index'*/);
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'config.toml'], () => gulp.start('hugo-preview')); });
gulp.task('build-dev', () => {
runSequence('pub-delete', ['sass', 'build:vendor', 'build:app', 'fonts', 'img'], 'hugo-dev' /*, 'hugo-search-index'*/);
});
gulp.task('hugo', (cb) => {
return spawn('hugo', ['--buildFuture'], { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
});
gulp.task('hugo-staging', (cb) => {
return spawn('hugo', ['--buildDrafts', '--buildFuture'], { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
});
gulp.task('hugo-dev', (cb) => {
return spawn('hugo', ['--buildDrafts', '--buildFuture', '--baseURL=http://localhost:9001'], { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
}); });
gulp.task('init-watch', () => { gulp.task('init-watch', () => {
@@ -53,40 +77,9 @@ gulp.task('init-watch', () => {
$.watch('node_modules/rancher-website-theme/**/*.scss', () => gulp.start('sass')); $.watch('node_modules/rancher-website-theme/**/*.scss', () => gulp.start('sass'));
$.watch('src/js/**/*.js', () => gulp.start('js-watch')); $.watch('src/js/**/*.js', () => gulp.start('js-watch'));
$.watch('src/img/**/*', () => gulp.start('img')); $.watch('src/img/**/*', () => gulp.start('img'));
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'node_modules/rancher-website-theme/**/*', 'config.toml'], () => gulp.start('hugo-dev'));
}); });
gulp.task('build', () => {
runSequence(['sass', 'build:vendor', 'build:app', 'fonts', 'img', 'pub-delete'], 'hugo');
});
gulp.task('build-dev', () => {
runSequence(['sass', 'build:vendor', 'build:app', 'fonts', 'img', 'pub-delete'], 'hugo-dev');
});
gulp.task('build-preview', () => {
runSequence(['sass', 'build:vendor', 'build:app', 'fonts', 'img', 'pub-delete'], 'hugo-preview');
});
gulp.task('hugo', (cb) => {
return spawn('hugo', { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
});
gulp.task('hugo-preview', (cb) => {
return spawn('hugo', ['--buildDrafts', '--buildFuture'], { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
});
gulp.task('hugo-dev', (cb) => {
return spawn('hugo', ['--buildDrafts', '--buildFuture', '--baseURL=http://localhost:9001/'], { stdio: 'inherit' }).on('close', (/* code */) => {
browserSync.reload();
cb();
});
});
// -- // --
@@ -174,11 +167,12 @@ gulp.task('cms-delete', () => {
return del(['static/admin'], { dot: true }); return del(['static/admin'], { dot: true });
}); });
gulp.task('pub-delete', () => { gulp.task('pub-delete', (cb) => {
return del(['public/**', '!public'], { del(['public/**', '!public'], {
// dryRun: true, // dryRun: true,
dot: true dot: true
}).then(paths => { }).then(paths => {
console.log('Files and folders deleted:\n', paths.join('\n'), '\nTotal Files Deleted: ' + paths.length + '\n'); console.log('Total Files Deleted: ' + paths.length + '\n');
cb();
}); });
}); });
+20
View File
@@ -0,0 +1,20 @@
map_hash_bucket_size 256;
map $request_uri $redirect_uri {
}
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
if ( $redirect_uri ) {
return 302 $redirect_uri;
}
}
+2 -1
View File
@@ -15,7 +15,6 @@
"babelify": "^8.0.0", "babelify": "^8.0.0",
"browser-sync": "^2.18.13", "browser-sync": "^2.18.13",
"browserify": "^16.1.1", "browserify": "^16.1.1",
"gulp": "^3.9.1",
"gulp-autoprefixer": "^5.0.0", "gulp-autoprefixer": "^5.0.0",
"gulp-babel": "^6.1.2", "gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
@@ -43,6 +42,8 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"gulp": "^3.9.1",
"hugo-search-index": "^0.4.1",
"lory.js": "^2.4.1", "lory.js": "^2.4.1",
"ml-stack-nav": "^1.1.2", "ml-stack-nav": "^1.1.2",
"rancher-website-theme": "https://github.com/rancherlabs/website-theme.git", "rancher-website-theme": "https://github.com/rancherlabs/website-theme.git",
+1 -1
View File
@@ -13,4 +13,4 @@ if [ ! -z "$1" ]; then
PORT=$1 PORT=$1
fi fi
docker run --rm -it -v $(pwd):/site rancherlabs/website:dev minify-images docker run --rm -it -v $(pwd):/site rancher/docs:dev minify-images
-2
View File
@@ -8,8 +8,6 @@ else
cd `dirname $CWD` cd `dirname $CWD`
fi fi
echo "Pulling Theme..." && \
docker pull rancherlabs/website-theme:latest && \
echo "Building Image..." && \ echo "Building Image..." && \
docker build -t rancher/docs:latest . && \ docker build -t rancher/docs:latest . && \
echo "Pushing Image..." && \ echo "Pushing Image..." && \