new file: Dockerfile

new file:   Jenkinsfile
	new file:   run.sh
Initial commit
This commit is contained in:
Jonathan Ervine 2020-02-25 17:09:52 +08:00
parent f95949b1bd
commit b93486036f
3 changed files with 67 additions and 0 deletions

24
Dockerfile Normal file
View File

@ -0,0 +1,24 @@
# Base on latest (edge) alpine image
FROM node:10-alpine
MAINTAINER Sven Fischer <sven@leiderfischer.de>
WORKDIR /src
RUN apk add --no-cache --virtual .build-deps \
git python make g++ \
&& apk add --no-cache openssh-client \
&& git clone https://github.com/krishnasrinivas/wetty --branch v1.1.4 /src \
&& npm install \
&& apk del .build-deps \
&& adduser -h /src -D term \
&& npm run-script build
ADD run.sh /src
# Default ENV params used by wetty
ENV REMOTE_SSH_SERVER=127.0.0.1 \
REMOTE_SSH_PORT=22
EXPOSE 3000
ENTRYPOINT "./run.sh"

26
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,26 @@
node("docker-node") {
docker.withRegistry('https://harbor.ervine.dev', 'jenkins-to-harbor') {
git branch: "3.11.3", url: "ssh://git@git.ervine.org:2222/jonny/x86_64-alpine-wetty", credentialsId: 'jenkins-to-git'
sh "git rev-parse HEAD > .git/commit-id"
def commit_id = readFile('.git/commit-id').trim()
println commit_id
try {
stage "build"
def app = docker.build "library/x86_64/alpine/wetty"
stage "publish"
app.push("${env.BUILD_NUMBER}")
app.push("latest")
stage('Deploy on K8s'){
sh "/usr/local/bin/kubectl -n utils delete po --all"
}
}
catch (err) {
currentBuild.result = 'FAILURE'
}
}
}

17
run.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
if [ "x${BASE}" == "x" ]; then
BASE="/"
fi
if [ "x${REMOTE_SSH_SERVER}" == "x" ]; then
# Login mode, no SSH_SERVER
npm start -- -p 3000
else
# SSH connect mode
cmd="npm start -- -p 3000 --sshhost ${REMOTE_SSH_SERVER} --sshport ${REMOTE_SSH_PORT} --base ${BASE}"
if ! [ "x${REMOTE_SSH_USER}" == "x" ]; then
cmd="${cmd} --sshuser ${REMOTE_SSH_USER}"
fi
su -c "${cmd}" term
fi