Commit 6d170a2b authored by Bartłomiej Górnicki's avatar Bartłomiej Górnicki

Revert "chore: change staging domain"

This reverts commit e327ca71.
parent 4e24914b
version: 2
jobs:
build:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t condenser .
- run:
name: Save Docker image
command: docker save -o condenser.tar condenser
- persist_to_workspace:
root: .
paths:
- condenser.tar
build-blackboxtest:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: docker build -t condenser-blackboxtest blackboxtest/
- run:
name: Save Docker image
command: docker save -o condenser-blackboxtest.tar condenser-blackboxtest
- persist_to_workspace:
root: .
paths:
- condenser-blackboxtest.tar
run-blackboxtest:
docker:
- image: docker:17-git
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: /tmp/workspace
- run:
name: Load Docker images
command: |
docker load -i /tmp/workspace/condenser.tar
docker load -i /tmp/workspace/condenser-blackboxtest.tar
- run:
name: Start condenser
command: |
docker run -ditp 8080:8080 --name condenser condenser
sleep 10 # let condenser start
- run:
name: Run tests
command: docker run --network container:condenser condenser-blackboxtest
workflows:
version: 2
condenser:
jobs:
- build
# - build-blackboxtest
# - run-blackboxtest:
# requires:
# - build
# - build-blackboxtest
node_modules
tmp
dist
lib
doc
.vscode
.idea
.storybook
blackboxtest
api_mockdata
package-lock.json
......@@ -5,63 +5,140 @@ find node_modules/eslint-config-airbnb -name '*.js'|xargs sed -i 's/\[2,/\[1,/'
find node_modules/eslint-config-airbnb -name '*.js'|xargs sed -i "s/': 2/': 1/"
*/
{
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"max-len": 0, /*[1, 160, 4],*/
"comma-dangle": 0,
"semi": [0],
"curly": [0],
"one-var": [0],
"eqeqeq": 0,
"no-cond-assign": 0,
"react/wrap-multilines": [0],
"one-var-declaration-per-line": [0],
"no-param-reassign": [0],
"no-nested-ternary": [0],
"no-undef": 2,
"camelcase": [0],
"no-console": [0],
"padded-blocks": 0,
"object-curly-spacing": [0],
"react/jsx-indent": [1,4],
"react/jsx-indent-props": [1,4],
"react/jsx-closing-bracket-location": [0],
"no-use-before-define": [0, {"functions": false, "classes": false}],
"spaced-comment": [0],
"prefer-template": [0],
"new-cap": [0],
"arrow-body-style": [0],
"func-names": [0],
"no-return-assign": 0,
"no-redeclare": 1,
"eol-last": 0,
"no-loop-func": 0,
"no-unneeded-ternary": 0, // false trigger const b = b ? b : a
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true,
"es6": true
},
"ignorePatterns": [
"jsPDF.min.js",
"SlateEditor/",
"assets"
],
"rules": {
"max-len": 0,
/*[1, 160, 4],*/
"comma-dangle": 0,
"semi": [
0
],
"curly": [
0
],
"one-var": [
0
],
"eqeqeq": 0,
"no-cond-assign": 0,
"react/wrap-multilines": [
0
],
"one-var-declaration-per-line": [
0
],
"no-param-reassign": [
0
],
"no-nested-ternary": [
0
],
"no-undef": 2,
"camelcase": [
0
],
"no-console": [
0
],
"padded-blocks": 0,
"object-curly-spacing": [
0
],
"react/jsx-indent": [
1,
4
],
"react/jsx-indent-props": [
1,
4
],
"react/jsx-closing-bracket-location": [
0
],
"no-use-before-define": [
0,
{
"functions": false,
"classes": false
}
],
"spaced-comment": [
0
],
"prefer-template": [
0
],
"new-cap": [
0
],
"arrow-body-style": [
0
],
"func-names": [
0
],
"no-return-assign": 0,
"no-redeclare": 1,
"eol-last": 0,
"no-loop-func": 0,
"no-unneeded-ternary": 0,
// false trigger const b = b ? b : a
/* Nice to haves */
/*"quotes": [1, "single", "avoid-escape"],*/ "quotes": 0,
/*"indent", [1,4], */ "indent": 0,
"brace-style": 0,
"space-infix-ops": 0,
"keyword-spacing": 0,
"no-confusing-arrow": 0,
"space-in-parens": 0,
"no-throw-literal": 0,
"react/sort-comp": [1, { "order": [ "lifecycle" ] }],
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"radix": 0,
"jsx-a11y/href-no-hash": "off",
"jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }],
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"import/extensions": 0
}
/* Nice to haves */
/*"quotes": [1, "single", "avoid-escape"],*/
"quotes": 0,
/*"indent", [1,4], */
"indent": 0,
"brace-style": 0,
"space-infix-ops": 0,
"keyword-spacing": 0,
"no-confusing-arrow": 0,
"space-in-parens": 0,
"no-throw-literal": 0,
"react/sort-comp": [
1,
{
"order": [
"lifecycle"
]
}
],
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"radix": 0,
"jsx-a11y/href-no-hash": "off",
"jsx-a11y/anchor-is-valid": [
"warn",
{
"aspects": [
"invalidHref"
]
}
],
"import/no-extraneous-dependencies": 0,
"import/no-unresolved": 0,
"import/extensions": 0
},
"overrides": [
{
"files": [
"**/*.test.js",
"**/*.test.jsx"
],
"env": {
"jest": true
}
}
]
}
.DS_Store
.idea
.vscode
coverage
node_modules
*.log
......@@ -8,4 +9,3 @@ vendor/*
tmp/*
.vagrant
lib
stages:
- build_staging
- restart_staging
- clean_up
build_staging:
stage: build_staging
script:
- echo "Building current develop branch"
- ./run.sh build stg
environment:
name: staging
only:
- develop
restart_staging:
stage: restart_staging
script:
- echo "Stopping current condenser image"
- ./run.sh stop stg
- echo "Starting latest condenser image"
- ./run.sh start stg
dependencies:
- build_staging
environment:
name: staging
only:
- develop
clean_up:
stage: clean_up
script:
- echo "Cleanup filespace / unused images / containers / networks"
- docker image prune -f
- docker container prune -f
- docker network prune -f
dependencies:
- restart_staging
environment:
name: staging
only:
- develop
- test
- build
- deploy
variables:
DOCKER_IMAGE: hiveio/condenser
APP_REVIEW_SUBDOMAIN: .condenser.engrave.dev
STAGING_DOMAIN: staging.condenser.engrave.dev
PRODUCTION_DOMAIN: hive.blog
CERTS: ~/.docker
################################# COMMON TEMPLATES #################################
.docker-job: &docker-job
image: docker:stable
services:
- docker:dind
before_script:
- echo $HUB_TOKEN | docker login -u $HUB_USERNAME --password-stdin
.docker-remote-host-review: &docker-remote-host-review
before_script:
- mkdir -p $CERTS
- echo "$REVIEW_TLSCACERT" > $CERTS/ca.pem
- echo "$REVIEW_TLSCERT" > $CERTS/cert.pem
- echo "$REVIEW_TLSKEY" > $CERTS/key.pem
- echo $CI_JOB_TOKEN | DOCKER_CERT_PATH=$CERTS docker -H $REVIEW_HOST --tlsverify login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
after_script:
- rm -R $CERTS
.docker-remote-host-staging: &docker-remote-host-staging
before_script:
- mkdir -p $CERTS
- echo "$STAGING_TLSCACERT" > $CERTS/ca.pem
- echo "$STAGING_TLSCERT" > $CERTS/cert.pem
- echo "$STAGING_TLSKEY" > $CERTS/key.pem
after_script:
- rm -fR $CERTS
.docker-remote-host-production: &docker-remote-host-production
before_script:
- mkdir -p $CERTS
- echo "$PRODUCTION_TLSCACERT" > $CERTS/ca.pem
- echo "$PRODUCTION_TLSCERT" > $CERTS/cert.pem
- echo "$PRODUCTION_TLSKEY" > $CERTS/key.pem
after_script:
- rm -fR $CERTS
################################# MERGE REQUESTS #################################
run-unit-tests:
stage: test
image: node:12.16.2
only:
- branches
- merge_requests
before_script:
- yarn install --frozen-lockfile --ignore-optional
script:
- yarn run ci:test
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
run-eslint:
stage: test
image: node:12.16.2
only:
- branches
- merge_requests
before_script:
- yarn install --frozen-lockfile --ignore-optional
script:
- yarn ci:eslint
allow_failure: true # will be changed to false when all linter errors removed
build-review-app:
<<: *docker-job
stage: build
variables:
DOCKER_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
SOURCE_COMMIT: $CI_COMMIT_SHA
only:
- merge_requests
before_script:
- echo $CI_JOB_TOKEN | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- docker build -t $DOCKER_TAG --build-arg SOURCE_COMMIT --build-arg DOCKER_TAG .
- docker push $DOCKER_TAG
deploy-review-app:
<<: *docker-job
<<: *docker-remote-host-review
stage: deploy
variables:
DOCKER_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
SERVICE_NAME: review_$CI_ENVIRONMENT_SLUG
only:
- merge_requests
script:
- DOCKER_CERT_PATH=$CERTS docker -H $REVIEW_HOST --tlsverify pull $DOCKER_TAG
- DOCKER_CERT_PATH=$CERTS docker -H $REVIEW_HOST --tlsverify service rm $SERVICE_NAME || true # try to remove previous service but do not fail if it not exist
- DOCKER_CERT_PATH=$CERTS docker -H $REVIEW_HOST --tlsverify service create --with-registry-auth --network infrastructure --name $SERVICE_NAME $DOCKER_TAG
- echo "Review app deployed"
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG$APP_REVIEW_SUBDOMAIN
on_stop: stop-review-app
auto_stop_in: 1 week
stop-review-app:
<<: *docker-job
<<: *docker-remote-host-review
stage: deploy
variables:
SERVICE_NAME: review_$CI_ENVIRONMENT_SLUG
only:
- merge_requests
when: manual
script:
- DOCKER_CERT_PATH=$CERTS docker -H $REVIEW_HOST --tlsverify service rm $SERVICE_NAME || true # try to remove previous service but do not fail if it not exist
- echo "Review app stopped"
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
################################# IMAGE BUILDING #################################
build-development:
<<: *docker-job
stage: build
variables:
DOCKER_TAG: $DOCKER_IMAGE:$CI_COMMIT_SHORT_SHA
DOCKER_TAG_MAIN: $DOCKER_IMAGE:development
SOURCE_COMMIT: $CI_COMMIT_SHA
only:
- develop
script:
- docker build -t $DOCKER_TAG -t $DOCKER_TAG_MAIN --build-arg SOURCE_COMMIT --build-arg DOCKER_TAG .
- docker push $DOCKER_TAG
- docker push $DOCKER_TAG_MAIN
build-production:
<<: *docker-job
stage: build
variables:
DOCKER_TAG: $DOCKER_IMAGE:$CI_COMMIT_SHORT_SHA
DOCKER_TAG_MAIN: $DOCKER_IMAGE:latest
SOURCE_COMMIT: $CI_COMMIT_SHA
only:
- master
script:
- docker build -t $DOCKER_TAG -t $DOCKER_TAG_MAIN --build-arg SOURCE_COMMIT --build-arg DOCKER_TAG .
- docker push $DOCKER_TAG
- docker push $DOCKER_TAG_MAIN
################################# DEPLOYMENT #################################
deploy-staging:
<<: *docker-job
<<: *docker-remote-host-staging
stage: deploy
variables:
DOCKER_TAG: $DOCKER_IMAGE:$CI_COMMIT_SHORT_SHA
SERVICE_NAME: staging_condenser
only:
- develop
script:
- DOCKER_CERT_PATH=$CERTS docker -H $STAGING_HOST --tlsverify pull $DOCKER_TAG
- DOCKER_CERT_PATH=$CERTS docker -H $STAGING_HOST --tlsverify service update --image $DOCKER_TAG --update-failure-action rollback --update-order start-first $SERVICE_NAME
environment:
name: staging
url: https://$STAGING_DOMAIN
deploy-production:
<<: *docker-job
<<: *docker-remote-host-production
stage: deploy
variables:
DOCKER_TAG: $DOCKER_IMAGE:$CI_COMMIT_SHORT_SHA
SERVICE_NAME: production_condenser
only:
- master
script:
- DOCKER_CERT_PATH=$CERTS docker -H $PRODUCTION_HOST --tlsverify pull $DOCKER_TAG
- DOCKER_CERT_PATH=$CERTS docker -H $PRODUCTION_HOST --tlsverify service update --image $DOCKER_TAG --update-failure-action rollback --update-order start-first $SERVICE_NAME
environment:
name: production
url: https://$PRODUCTION_DOMAIN
FROM node:8.7
FROM node:12.16.2 as development
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT ${SOURCE_COMMIT}
ARG DOCKER_TAG
ENV DOCKER_TAG ${DOCKER_TAG}
# yarn > npm
#RUN npm install --global yarn
WORKDIR /var/app
RUN npm install -g yarn
COPY package.json yarn.lock ./
WORKDIR /var/app
RUN mkdir -p /var/app
ADD package.json yarn.lock /var/app/
RUN yarn install --non-interactive --frozen-lockfile --ignore-optional
COPY . /var/app
COPY . .
# FIXME TODO: fix eslint warnings
RUN mkdir tmp && yarn build
#RUN mkdir tmp && \
# npm test && \
# ./node_modules/.bin/eslint . && \
# npm run build
CMD [ "yarn", "run", "start" ]
RUN mkdir tmp && \
yarn test && yarn build
### REMOVE DEV DEPENDENCIES ##
FROM development as dependencies
ENV PORT 8080
ENV NODE_ENV production
RUN yarn install --non-interactive --frozen-lockfile --ignore-optional --production
EXPOSE 8080
### BUILD MINIFIED PRODUCTION ##
FROM node:12.16.2-alpine as production
CMD [ "yarn", "run", "production" ]
WORKDIR /var/app
# uncomment the lines below to run it in development mode
# ENV NODE_ENV development
# CMD [ "yarn", "run", "start" ]
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT ${SOURCE_COMMIT}
ARG DOCKER_TAG
ENV DOCKER_TAG ${DOCKER_TAG}
COPY --from=dependencies /var/app/package.json /var/app/package.json
COPY --from=dependencies /var/app/config /var/app/config
COPY --from=dependencies /var/app/dist /var/app/dist
COPY --from=dependencies /var/app/lib /var/app/lib
COPY --from=dependencies /var/app/src /var/app/src
COPY --from=dependencies /var/app/tmp /var/app/tmp
COPY --from=dependencies /var/app/webpack /var/app/webpack
COPY --from=dependencies /var/app/node_modules /var/app/node_modules
COPY --from=dependencies /var/app/healthcheck.js /var/app/healthcheck.js
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=5 CMD node /var/app/healthcheck.js
CMD [ "yarn", "run", "production" ]
default: test
test: node_modules
npm test
node_modules:
yarn install
build:
docker build -t steemit/steemit.com .
clean:
rm -rf node_modules *.log tmp npm-debug.log.*
vagrant:
vagrant destroy -f
vagrant up
......@@ -23,10 +23,13 @@ like this:
```bash
git clone https://gitlab.syncad.com/hive/condenser
cd condenser
docker build -t="myname/condenser:mybranch" .
docker run -it -p 8080:8080 myname/condenser:mybranch
./run.sh start dev
```
To build developer image manually, you can use:
`docker build --target development --tag condenser:dev .`
#### Docker Compose
If you like to run and build condenser and additionally a reverse-proxy using an Nginx Docker image, with companion Letsencrypt (SSL) support, you can simple launch the Docker-compose files via the included `run.sh`-scripts.
......
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/xenial64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port