Compare commits

...

5 Commits

Author SHA1 Message Date
garionion d45d1ad56f
set API URL on build time
Signed-off-by: garionion <github@entr0py.de>
2021-04-04 17:30:02 +02:00
Alexander Detsch 3335c68e80 Merge branch 'add_ci' into main 2021-04-04 16:48:44 +02:00
Alexander Detsch 41f19acd8c Merge branch 'main' into add_ci 2021-04-04 16:39:54 +02:00
Alexander Detsch a42122213b changed build image 2021-04-04 15:51:45 +02:00
Alexander Detsch e24b0f3660 added ci/cd 2021-04-04 15:35:36 +02:00
9 changed files with 115 additions and 26 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
.git
.dockerignore

1
.env.production Normal file
View File

@ -0,0 +1 @@
VITE_API_URL=https://psp.dets.ch/api

53
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,53 @@
stages:
- build
- deploy
variables:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
ANSIBLE_PYTHON_INTERPRETER: auto_silent
ANSIBLE_STDOUT_CALLBACK: debug
docker-build-master:
# Official docker image.
image: docker:latest
stage: build
tags:
- docker
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
docker-build:
# Official docker image.
image: docker:latest
stage: build
tags:
- docker
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- main
deploy-master:
#when: manual
stage: deploy
image:
name: cytopia/ansible:latest-tools
entrypoint: [""]
script:
- chmod 600 "${ANSIBLE_SSH_KEY_PRIVATE}"
- ansible-playbook -i ./deployment/hosts.yml --private-key "${ANSIBLE_SSH_KEY_PRIVATE}" "./deployment/deployment.yml"
only:
- main

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM node:alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,27 +1,4 @@
# Vue 3 + Typescript + Vite
# Radiator-Web
This template should help get you started developing with Vue 3 and Typescript in Vite.
API URL must be set on Build Time, either via Env `API_URL`(prefered), or via `VITE_API_URL` from [`.env.production`](.env.production)
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Vetur](https://marketplace.visualstudio.com/items?itemName=octref.vetur). Make sure to enable `vetur.experimental.templateInterpolationService` in settings!
### If Using `<script setup>`
[`<script setup>`](https://github.com/vuejs/rfcs/pull/227) is a feature that is currently in RFC stage. To get proper IDE support for the syntax, use [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) instead of Vetur (and disable Vetur).
## Type Support For `.vue` Imports in TS
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can use the following:
### If Using Volar
Run `Volar: Switch TS Plugin on/off` from VSCode command palette.
### If Using Vetur
1. Install and add `@vuedx/typescript-plugin-vue` to the [plugins section](https://www.typescriptlang.org/tsconfig#plugins) in `tsconfig.json`
2. Delete `src/shims-vue.d.ts` as it is no longer needed to provide module info to Typescript
3. Open `src/main.ts` in VSCode
4. Open the VSCode command palette
5. Search and run "Select TypeScript version" -> "Use workspace version"

22
deployment/deployment.yml Normal file
View File

@ -0,0 +1,22 @@
---
- hosts: snickers-docker
gather_facts: no
vars:
verbose: false
compose_folder: "/mnt/docker-storage/radiator-web/"
tasks:
- name: Ensures {{ compose_folder }} dir exists
stat:
path: "{{ compose_folder }}docker-compose.yml"
register: file_details
- name: Fail if docker-compose file doesn't exist
fail:
msg: "docker-compose.yml doesn't exist in expected location (expected in {{ compose_folder }})"
when: not file_details.stat.exists
- name: Update container image
community.general.docker_compose:
project_src: "{{ compose_folder }}"
pull: yes

10
deployment/hosts.yml Normal file
View File

@ -0,0 +1,10 @@
all:
vars:
ansible_python_interpreter: /usr/bin/python3
hosts:
snickers-docker:
ansible_host: 192.168.200.11
ansible_port: 22
ansible_user: root
ansible_ssh_extra_args: '-o StrictHostKeyChecking=no'
ansible_ssh_common_args: '-o ProxyCommand="ssh -o StrictHostKeyChecking=no -i "${ANSIBLE_SSH_KEY_PRIVATE}" -W %h:%p root@vserver8.alex-detsch.de -p 52"'

12
docker-compose.yml Normal file
View File

@ -0,0 +1,12 @@
web:
image: registry.alex-detsch.de/fem/radiator/radiator-web
restart: always
healthcheck:
test: "curl localhost"
interval: "60s"
timeout: "3s"
start_period: "5s"
retries: 3
stop_grace_period: 3s
ports:
- "1499:80"

View File

@ -16,7 +16,7 @@ const enum HTTPMethod {
PATCH = "PATCH",
}
const url = "http://192.168.178.5:8080/api";
const url = import.meta.env.API_URL ?? import.meta.env.VITE_API_URL;
let token: token;
let ready = false;