mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-12 12:07:20 +00:00
Packaging
This commit is contained in:
+28
-3
@@ -1,9 +1,34 @@
|
||||
---
|
||||
pipeline:
|
||||
docker-publish-master:
|
||||
docker-publish-dev:
|
||||
group: publish
|
||||
image: plugins/docker
|
||||
dockerfile: Dockerfile
|
||||
repo: rancherlabs/website
|
||||
dockerfile: Dockerfile.dev
|
||||
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: .
|
||||
tag: latest
|
||||
secrets: [docker_username, docker_password]
|
||||
|
||||
+2
-2
@@ -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 \
|
||||
&& 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 \
|
||||
python-pygments git ca-certificates asciidoc nodejs yarn jq \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 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
|
||||
|
||||
ADD https://github.com/spf13/hugo/releases/download/v${HUGO_VERSION}/${HUGO_BINARY} /tmp/hugo.deb
|
||||
|
||||
+7
-25
@@ -1,30 +1,8 @@
|
||||
FROM debian:jessie
|
||||
FROM rancher/docs:build
|
||||
|
||||
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
|
||||
|
||||
RUN npm install -g gulp && yarn
|
||||
COPY package.json /run/
|
||||
|
||||
RUN ln -s /site/config.toml /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/layouts /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/
|
||||
|
||||
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 9001
|
||||
|
||||
|
||||
@@ -2,19 +2,21 @@ FROM rancher/docs:build as build
|
||||
|
||||
WORKDIR /run
|
||||
|
||||
COPY --from=rancherlabs/website-theme:latest /src/website-theme /run/node_modules/rancher-website-theme
|
||||
COPY gulpfile.babel.js /run/
|
||||
COPY .eslintrc.js /run/
|
||||
COPY config.toml /run/
|
||||
COPY netlify.toml /run/
|
||||
COPY archetypes archetypes
|
||||
COPY content content
|
||||
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
|
||||
|
||||
# Make sure something got built
|
||||
@@ -22,3 +24,4 @@ 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
|
||||
@@ -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
@@ -16,6 +16,8 @@ const $ = gulpLoadPlugins();
|
||||
const browserSync = require('browser-sync').create();
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
require('hugo-search-index/gulp')(gulp);
|
||||
|
||||
const onError = (err) => {
|
||||
console.log(err);
|
||||
}
|
||||
@@ -28,17 +30,39 @@ process.on('SIGINT', () => {
|
||||
// --
|
||||
gulp.task('dev', ['build-dev'], () => {
|
||||
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.start('init-watch');
|
||||
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'config.toml'], () => gulp.start('hugo'));
|
||||
gulp.task('build', () => {
|
||||
runSequence('pub-delete', ['sass', 'build:vendor', 'build:app', 'fonts', 'img'], 'hugo' /*, 'hugo-search-index'*/);
|
||||
});
|
||||
|
||||
gulp.task('server:with-drafts', ['build-preview'], () => {
|
||||
gulp.start('init-watch');
|
||||
$.watch(['archetypes/**/*', 'data/**/*', 'content/**/*', 'layouts/**/*', 'static/**/*', 'themes/**/*', 'config.toml'], () => gulp.start('hugo-preview'));
|
||||
gulp.task('build-staging', () => {
|
||||
runSequence('pub-delete', ['sass', 'build:vendor', 'build:app', 'fonts', 'img'], 'hugo-staging' /*, 'hugo-search-index'*/);
|
||||
});
|
||||
|
||||
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', () => {
|
||||
@@ -53,40 +77,9 @@ gulp.task('init-watch', () => {
|
||||
$.watch('node_modules/rancher-website-theme/**/*.scss', () => gulp.start('sass'));
|
||||
$.watch('src/js/**/*.js', () => gulp.start('js-watch'));
|
||||
$.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 });
|
||||
});
|
||||
|
||||
gulp.task('pub-delete', () => {
|
||||
return del(['public/**', '!public'], {
|
||||
gulp.task('pub-delete', (cb) => {
|
||||
del(['public/**', '!public'], {
|
||||
// dryRun: true,
|
||||
dot: true
|
||||
}).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
@@ -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
@@ -15,7 +15,6 @@
|
||||
"babelify": "^8.0.0",
|
||||
"browser-sync": "^2.18.13",
|
||||
"browserify": "^16.1.1",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-autoprefixer": "^5.0.0",
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-concat": "^2.6.1",
|
||||
@@ -43,6 +42,8 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"hugo-search-index": "^0.4.1",
|
||||
"lory.js": "^2.4.1",
|
||||
"ml-stack-nav": "^1.1.2",
|
||||
"rancher-website-theme": "https://github.com/rancherlabs/website-theme.git",
|
||||
|
||||
@@ -13,4 +13,4 @@ if [ ! -z "$1" ]; then
|
||||
PORT=$1
|
||||
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
|
||||
|
||||
@@ -8,8 +8,6 @@ else
|
||||
cd `dirname $CWD`
|
||||
fi
|
||||
|
||||
echo "Pulling Theme..." && \
|
||||
docker pull rancherlabs/website-theme:latest && \
|
||||
echo "Building Image..." && \
|
||||
docker build -t rancher/docs:latest . && \
|
||||
echo "Pushing Image..." && \
|
||||
|
||||
Reference in New Issue
Block a user