diff --git a/.deploy.yml b/.deploy.yml new file mode 100644 index 0000000..611f71f --- /dev/null +++ b/.deploy.yml @@ -0,0 +1,6 @@ +sn48: + vault: + hydrate: + branches: + - master + deploy: 4 diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..ae04ec2 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,157 @@ +kind: pipeline +type: docker +name: default +trigger: + branch: + - traefik + - master + +steps: +- name: debug-secrets + image: alpine + environment: + VAULT_API_URL: + from_secret: VAULT_API_URL + commands: + - 'echo "VAULT_API_URL $${VAULT_API_URL}"' + when: + event: + - push + - tag + +# Make the image available for next step +- name: publish + image: plugins/docker + settings: + build_args: + - VITE_LOGGER_LOG=1 + - VITE_LOGGER_DEBUG=1 + - VITE_APPLICATION_NAME=Calendar + - VITE_APPLICATION_HANDLE=calendar + - VITE_DEFAULT_LANG=en + - VITE_APP_VERSION=0.1.0 + dockerfile: Dockerfile + context: . + registry: registry.sn48.zivili.ch + repo: registry.sn48.zivili.ch/meow/calendar-react + tags: + - "amd64-0.1.0" + - "latest" + username: + from_secret: PORTUS_USER + password: + from_secret: PORTUS_PASSWORD + debug: true + launch_debug: true + # make sure to replace image with same tag + force_tag: true + when: + event: + - push + - tag + +## BEGIN - GENERIC DEPLOY CONIFG + +- name: deploy + image: registry.sn48.zivili.ch/meow/drone-deploy:amd64-1.0.0 + pull: never + settings: + ssh_port: + from_secret: SSH_PORT + # this is required for the moment to generate the .docker/config.json + # drone is failing to do it on its own at the moment + dockerconfigjson: + from_secret: dockerconfigjson + # use portus or directly docker logins + portus_user: + from_secret: PORTUS_USER + portus_password: + from_secret: PORTUS_PASSWORD + # used by deploy to login to deploy server + ssh_host: + from_secret: SSH_HOST + ssh_user: + from_secret: SSH_USER + ssh_key: + from_secret: SSH_KEY + ssh_fingerprint: + from_secret: SSH_FINGERPRINT + # used by the deploy script to gather all project's .env values from vault + drone_agent1_token: + from_secret: DRONE_AGENT1_TOKEN + # used by deploy script to know where to gather secrets from + vault_api_url: + from_secret: VAULT_API_URL + +--- +kind: secret +name: SSH_HOST +get: + path: kv/data/__drone-admin-secrets + name: SSH_HOST + +--- +kind: secret +name: SSH_USER +get: + path: kv/data/__drone-admin-secrets + name: SSH_USER + +--- +kind: secret +name: SSH_KEY +get: + path: kv/data/__drone-admin-secrets + name: SSH_KEY + +--- +kind: secret +name: DRONE_AGENT1_TOKEN +get: + path: kv/data/__drone-admin-secrets + name: DRONE_AGENT1_TOKEN + +--- +kind: secret +name: VAULT_API_URL +get: + path: kv/data/__drone-admin-secrets + name: VAULT_API_URL + +--- +kind: secret +name: PORTUS_USER +get: + path: kv/data/__drone-admin-secrets + name: PORTUS_USER + +--- +kind: secret +name: PORTUS_PASSWORD +get: + path: kv/data/__drone-admin-secrets + name: PORTUS_PASSWORD + +--- +kind: secret +name: dockerconfigjson +get: + path: kv/data/__drone-admin-secrets + name: dockerconfigjson + +image_pull_secrets: + from_secret: dockerconfigjson + +--- +kind: secret +name: SSH_PORT +get: + path: kv/data/__drone-admin-secrets + name: SSH_PORT + +--- +kind: secret +name: SSH_FINGERPRINT +get: + path: kv/data/__drone-admin-secrets + name: SSH_FINGERPRINT \ No newline at end of file diff --git a/.gitignore b/.gitignore index c2658d7..6f00be3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,27 @@ -node_modules/ +dist/ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local +.env.prod +# vault +.env.vault + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12dbefd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +# Prepare two environments +# 0. where the application is built +# 1. where the applicatoin is run +# https://cloud.google.com/community/tutorials/deploy-react-nginx-cloud-run +# https://www.youtube.com/watch?v=Sm8GbC02MlE + +# FROM node:alpine3.12 as npmi-stage +FROM node:current-alpine as build-stage +# any dir you want actually +WORKDIR /app + +# Declare build arguments +ARG VITE_APPLICATION_NAME +ARG VITE_APPLICATION_HANDLE +ARG VITE_DEFAULT_LANG +ARG VITE_APP_VERSION + +# Copy package.json and package-lock.json +COPY package.json ./ + +# Set environment variables +ENV VITE_APPLICATION_HANDLE=${VITE_APPLICATION_HANDLE} +ENV VITE_APPLICATION_NAME=${VITE_APPLICATION_NAME} +ENV VITE_DEFAULT_LANG=${VITE_DEFAULT_LANG} +ENV VITE_APP_VERSION=${VITE_APP_VERSION} + +# Install dependencies +RUN npm install + +# Copy the rest of your app's source code from your host to your image filesystem. +COPY . . + +# Build the application +RUN npm run build + +# Stage 2: Setup the server environment +FROM nginx:alpine as deploy-stage + +# Copy custom nginx config +COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf + +# Set working directory to nginx asset directory +WORKDIR /usr/share/nginx/html + +# Remove default nginx static assets +RUN rm -rf ./* + +# Copy static assets from builder stage +COPY --from=build-stage /app/dist . + +# Containers run nginx with global directives and daemon off +ENTRYPOINT ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c42dcbc --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.9' + +services: + biblio-stats-react: + container_name: ${REVERSE_DOMAIN} + image: "${DOCKER_IMAGE}" + labels: + - "traefik.enable=true" + - "traefik.http.routers.${REVERSE_DOMAIN}.rule=Host(`${APPLICATION_DOMAIN_NAME}`)" + - "traefik.http.routers.${REVERSE_DOMAIN}.entrypoints=websecure" + - "traefik.http.routers.${REVERSE_DOMAIN}.tls.certresolver=myresolver" + - "traefik.http.services.${REVERSE_DOMAIN}.loadbalancer.server.port=80" + - "traefik.docker.network=shared_network" + networks: + - shared_network + restart: always + +networks: + shared_network: + name: shared_network + external: true \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..4e991f7 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,15 @@ +server { + listen 80; + root /usr/share/nginx/html; + include /etc/nginx/mime.types; + + location / { + index index.html; + try_files $uri $uri/ /index.html; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +} \ No newline at end of file diff --git a/sorted_colors.txt b/sorted_colors.txt deleted file mode 100644 index d2b11c2..0000000 --- a/sorted_colors.txt +++ /dev/null @@ -1,86 +0,0 @@ - -$border-color; -$border-color; // replaced shared.$border-color -$content-normal-bg; // replaced shared.$content-background-color -$content-normal-bg; // replaced shared.$content-background-color-selecting -$content-normal-text; // replaced shared.$content-color -$day-content-defaultmode-defaultstate-background-color; -$day-content-defaultmode-defaultstate-color; -$day-content-defaultmode-defaultstate-color; // replaced shared.$day-content-defaultmode-defaultstate-color -$day-content-defaultmode-selectedstate-midrange-background-color; -$day-content-defaultmode-selectedstate-midrange-color; -$day-content-defaultmode-selectedstate-rangeend-background-color; -$day-content-defaultmode-selectedstate-rangeend-color; -$day-content-defaultmode-selectedstate-rangeend-hover-background-color; -$day-content-defaultmode-selectedstate-rangestart-background-color; -$day-content-defaultmode-selectedstate-rangestart-color; -$day-content-defaultmode-selectedstate-rangestart-hover-background-color; -$day-content-defaultmode-selectingstate-midrange-background-color; -$day-content-defaultmode-selectingstate-midrange-color; -$day-content-defaultmode-selectingstate-midrange-hover-background-color; -$day-content-defaultmode-selectingstate-rangeend-background-color; -$day-content-defaultmode-selectingstate-rangeend-color; -$day-content-defaultmode-selectingstate-rangeend-hover-background-color; -$day-content-defaultmode-selectingstate-rangestart-background-color; -$day-content-defaultmode-selectingstate-rangestart-color; -$day-content-defaultmode-selectingstate-rangestart-hover-background-color; -$day-content-greyedmode-defaultstate-background-color; -$day-content-greyedmode-defaultstate-color; -$day-content-greyedmode-selectedstate-midrange-background-color; -$day-content-greyedmode-selectedstate-midrange-color; -$day-content-greyedmode-selectedstate-rangeend-background-color; -$day-content-greyedmode-selectedstate-rangeend-color; -$day-content-greyedmode-selectedstate-rangeend-hover-background-color; -$day-content-greyedmode-selectedstate-rangestart-background-color; -$day-content-greyedmode-selectedstate-rangestart-color; -$day-content-greyedmode-selectedstate-rangestart-hover-background-color; -$day-content-greyedmode-selectingstate-midrange-background-color; -$day-content-greyedmode-selectingstate-midrange-color; -$day-content-greyedmode-selectingstate-rangeend-background-color; -$day-content-greyedmode-selectingstate-rangeend-color; -$day-content-greyedmode-selectingstate-rangeend-hover-background-color; -$day-content-greyedmode-selectingstate-rangestart-background-color; -$day-content-greyedmode-selectingstate-rangestart-color; -$day-content-greyedmode-selectingstate-rangestart-hover-background-color; -$day-header-defaultmode-defaultstate-background-color; -$day-header-defaultmode-defaultstate-color; -$day-header-defaultmode-selectedstate-midrange-background-color; -$day-header-defaultmode-selectedstate-midrange-color; -$day-header-defaultmode-selectedstate-rangeend-background-color; -$day-header-defaultmode-selectedstate-rangeend-color; -$day-header-defaultmode-selectedstate-rangeend-hover-background-color; -$day-header-defaultmode-selectedstate-rangestart-background-color; -$day-header-defaultmode-selectedstate-rangestart-color; -$day-header-defaultmode-selectedstate-rangestart-hover-background-color; -$day-header-defaultmode-selectingstate-midrange-background-color; -$day-header-defaultmode-selectingstate-midrange-color; -$day-header-defaultmode-selectingstate-rangeend-background-color; -$day-header-defaultmode-selectingstate-rangeend-color; -$day-header-defaultmode-selectingstate-rangeend-hover-background-color; -$day-header-defaultmode-selectingstate-rangestart-background-color; -$day-header-defaultmode-selectingstate-rangestart-color; -$day-header-defaultmode-selectingstate-rangestart-hover-background-color; -$day-header-greyedmode-defaultstate-background-color; -$day-header-greyedmode-defaultstate-background-color; // replaced shared.$header-background-color-greyed -$day-header-greyedmode-defaultstate-color; -$day-header-greyedmode-defaultstate-color; // replaced shared.$header-color-greyed -$day-header-greyedmode-selectedstate-midrange-background-color; -$day-header-greyedmode-selectedstate-midrange-color; -$day-header-greyedmode-selectedstate-rangeend-background-color; -$day-header-greyedmode-selectedstate-rangeend-color; -$day-header-greyedmode-selectedstate-rangeend-hover-background-color; -$day-header-greyedmode-selectedstate-rangestart-background-color; -$day-header-greyedmode-selectedstate-rangestart-color; -$day-header-greyedmode-selectedstate-rangestart-hover-background-color; -$day-header-greyedmode-selectingstate-midrange-background-color; -$day-header-greyedmode-selectingstate-midrange-color; -$day-header-greyedmode-selectingstate-rangeend-background-color; -$day-header-greyedmode-selectingstate-rangeend-color; -$day-header-greyedmode-selectingstate-rangeend-hover-background-color; -$day-header-greyedmode-selectingstate-rangestart-background-color; -$day-header-greyedmode-selectingstate-rangestart-color; -$day-header-greyedmode-selectingstate-rangestart-hover-background-color; -$focus-blue; -$header-normal-bg; // replaced shared.$header-background-color -$header-normal-text; // replaced shared.$header-color -scss) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..33e8599 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react", + "paths": { + "react": [ "./node_modules/@types/react" ] + }, + "noFallthroughCasesInSwitch": true + }, + "include": [ + "src", + "server.js" + ] +}