Skip to content

Commit

Permalink
Merge pull request #1356 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
Fix error logging, Safer sentry and docker login
  • Loading branch information
Rochet2 authored Aug 28, 2019
2 parents ce75aa2 + 1887ada commit 2126e03
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 39 deletions.
16 changes: 11 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ jobs:
echo $CIRCLE_TAG;
if [[ -n "$CIRCLE_TAG" ]]; then
echo 'export TAG=latest' >> $BASH_ENV;
echo 'export NOTIFY_DEPLOY=true' >> $BASH_ENV;
echo 'export DEPLOY=true' >> $BASH_ENV;
echo 'export CACHE_TAG=staging' >> $BASH_ENV;
echo 'USING RELEASE CONFIG';
elif [[ "$CIRCLE_BRANCH" = "master" && -z "$CIRCLE_PULL_REQUEST" ]]; then
echo 'export TAG=staging' >> $BASH_ENV;
echo 'export NOTIFY_DEPLOY=true' >> $BASH_ENV;
echo 'export DEPLOY=true' >> $BASH_ENV;
echo 'export CACHE_TAG=trunk' >> $BASH_ENV;
echo 'USING STAGING CONFIG';
else
echo 'export TAG=trunk' >> $BASH_ENV;
echo 'export NOTIFY_DEPLOY=false' >> $BASH_ENV;
echo 'export DEPLOY=false' >> $BASH_ENV;
echo 'export CACHE_TAG=trunk' >> $BASH_ENV;
echo 'USING TRUNK CONFIG';
fi
Expand Down Expand Up @@ -78,9 +78,15 @@ jobs:
path: cypress/screenshots
- deploy:
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
if [ "${DEPLOY}" == "true" ]; then
docker exec --env SENTRY_URL --env SENTRY_AUTH_TOKEN --env SENTRY_ORG=sentry --env SENTRY_PROJECT=oodifront frontend \
sh -c 'npm run sentry-cli -- releases new --finalize "$(cat /SENTRY_RELEASE_VERSION)" && \
npm run sentry-cli -- releases files "$(cat /SENTRY_RELEASE_VERSION)" upload-sourcemaps --rewrite dist'
fi
echo "$DOCKER_PASS" > DOCKER_PASS
cat DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
npm run docker:ci -- push
if [ "${NOTIFY_DEPLOY}" == "true" ]; then
if [ "${DEPLOY}" == "true" ]; then
curl --silent -X POST -H 'Content-type: application/json' --data "{\"text\":\"${CIRCLE_BRANCH}${CIRCLE_TAG} started auto deployment!\"}" ${SLACKBOT_URL}
fi
Expand Down
4 changes: 0 additions & 4 deletions docker/docker-compose.lateste2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ services:
build:
args:
BASE_PATH: /
SENTRY_URL: ${SENTRY_URL}
SENTRY_AUTH_TOKEN: ${SENTRY_AUTH_TOKEN}
SENTRY_ORG: sentry
SENTRY_PROJECT: oodifront
cache_from:
- toska/oodikone2-frontend:trunk
- toska/oodikone2-frontend:staging
Expand Down
8 changes: 3 additions & 5 deletions services/oodikone2-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ RUN npm ci

ARG BASE_PATH=/
ENV BASE_PATH=$BASE_PATH
ARG SENTRY_URL
ARG SENTRY_AUTH_TOKEN
ARG SENTRY_ORG
ARG SENTRY_PROJECT
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
RUN if [ "${NODE_ENV}" != "production" ]; then cp -r /usr/src/app/node_modules /usr/src/cache/node_modules; fi

COPY . /usr/src/app
RUN if [ "${NODE_ENV}" != "development" ]; then \
export CHECKSUM="$(find . ! -path */node_modules/* -type f -exec md5sum {} \; | sort -k 2 | printf "$(cat - )\\nBASE_PATH ${BASE_PATH}" | md5sum | awk '{ print $1 }')" && \
SENTRY_RELEASE_VERSION="${NODE_ENV}-${CHECKSUM}" npm run dist && \
export SENTRY_RELEASE_VERSION="${NODE_ENV}-${CHECKSUM}" && \
echo "${SENTRY_RELEASE_VERSION}" > /SENTRY_RELEASE_VERSION && \
SENTRY_RELEASE_VERSION="${SENTRY_RELEASE_VERSION}" npm run dist && \
npm install -g serve; \
fi
14 changes: 3 additions & 11 deletions services/oodikone2-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion services/oodikone2-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lint:css": "stylelint 'src/**/*.css'",
"lint:js": "eslint server ./ --ext .jsx,.js",
"lintfix": "eslint server ./ --ext .jsx,.js --fix",
"sentry-cli": "sentry-cli",
"stats": "webpack --json --mode=production --profile --progress > stats.json",
"test": "npm run lint",
"test_docker": "docker exec -t frontend /bin/bash -c 'npm test'",
Expand Down Expand Up @@ -57,7 +58,7 @@
"@babel/preset-env": "^7.5.5",
"@babel/preset-react": "^7.0.0",
"@sentry/browser": "^4.6.6",
"@sentry/webpack-plugin": "^1.7.0",
"@sentry/cli": "^1.47.1",
"axios": "^0.18.1",
"babel-polyfill": "^6.26.0",
"dotenv": "^6.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const retry = async (fn, retriesLeft = 3, interval = 500) => (
resolve(null)
window.location.reload()
} else {
error(null)
reject(error)
}
return
}
Expand Down
15 changes: 3 additions & 12 deletions services/oodikone2-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const TerserPlugin = require('terser-webpack-plugin')
const DeadCodePlugin = require('webpack-deadcode-plugin')
const SentryWebpackPlugin = require('@sentry/webpack-plugin')

const devServerPort = 8081
const apiServerPort = 8080
const apiAddress = process.env.BACKEND_ADDR || 'localhost'
const backendURL = `http://${apiAddress}:${apiServerPort}`
const BASE_PATH = process.env.BASE_PATH || '/'
const { SENTRY_RELEASE_VERSION, SENTRY_PROJECT, SENTRY_ORG, SENTRY_URL } = process.env
const noSentryVersion = !Boolean(SENTRY_RELEASE_VERSION)
const { SENTRY_RELEASE_VERSION } = process.env
const noSentryVersion = !SENTRY_RELEASE_VERSION
const sentryreleaseversion = noSentryVersion ? 'unknown' : SENTRY_RELEASE_VERSION
const sentryDryRun = noSentryVersion || !Boolean(SENTRY_PROJECT) || !Boolean(SENTRY_ORG) || !Boolean(SENTRY_URL)

console.log('sentry settings:', { sentryDryRun, SENTRY_RELEASE_VERSION })
console.log('sentry settings:', { SENTRY_RELEASE_VERSION })

module.exports = (env, args) => {
const { mode } = args
Expand Down Expand Up @@ -86,13 +84,6 @@ module.exports = (env, args) => {
new MiniCssExtractPlugin({
filename: '[name]-[hash].css',
chunkFilename: '[id]-[hash].css'
}),
new SentryWebpackPlugin({
include: 'dist',
ignoreFile: '.sentrycliignore',
ignore: ['node_modules', 'webpack.config.js'],
release: sentryreleaseversion,
dryRun: sentryDryRun
})
],
optimization: {
Expand Down

0 comments on commit 2126e03

Please sign in to comment.