diff --git a/.dockerignore b/.dockerignore index b143673..a96bd42 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,42 +1,20 @@ * -# =====BACKEND===== -## Source code +# Source code !src/ -## Cargo files +# Cargo files !Cargo.toml !Cargo.lock -## Entrypoint for devop container +# Entrypoint for devop container !docker/entrypoint_dev.sh !docker/entrypoint.sh -## Config file +# Config file !Rocket.toml -## Database migrations +# Database migrations !migrations/ -## Crontab for release container !docker/crontab - - -# =====FRONTEND===== -## Source code -!web/src/ - -## Public assets -!web/public/ -!web/index.html - -## Production env file -!web/.env.production - -## Package manager stuff -!web/package.json -!web/yarn.lock - -## Project configs -!web/tsconfig.json -!web/vite.config.ts diff --git a/.woodpecker.yml b/.woodpecker.yml index 6199967..78e9241 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,18 +1,9 @@ pipeline: - build-frontend: - image: node:15-alpine3.13 - pull: true - commands: - - cd web && yarn install - - cd web && yarn run build - - test-backend: + test: image: chewingbever/fej-builder:latest # Always update the builder image pull: true commands: - cargo test - # TODO build dev & rel image, deploy these images - branches: [ master, develop ] diff --git a/Cargo.toml b/Cargo.toml index cf6db71..97668d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,10 +4,6 @@ version = "1.0.2" authors = ["Jef Roosens "] edition = "2018" -[features] -# Enables hosting of the frontend -frontend = [] - [lib] name = "fej" path = "src/fej/lib.rs" @@ -45,4 +41,4 @@ diesel_migrations = "1.4.0" [dependencies.rocket_contrib] version = "0.4.7" default-features = false -features = ["json", "diesel_postgres_pool", "serve"] +features = ["json", "diesel_postgres_pool"] diff --git a/docker/Dockerfile.rel b/docker/Dockerfile.rel index 5a17f05..4bffeae 100644 --- a/docker/Dockerfile.rel +++ b/docker/Dockerfile.rel @@ -1,5 +1,5 @@ # vim: filetype=dockerfile -FROM chewingbever/fej-builder:latest AS backend-builder +FROM chewingbever/fej-builder:latest AS builder COPY --chown=builder:builder Cargo.toml Cargo.lock ./ COPY --chown=builder:builder src/ ./src/ @@ -19,18 +19,7 @@ COPY --chown=builder:builder migrations/ ./migrations/ RUN cargo install \ --path . \ --root /app/output \ - --target x86_64-unknown-linux-musl \ - --features frontend - - -FROM node:15-alpine3.13 AS frontend-builder - -COPY ./web /app -WORKDIR /app - -# Build the frontend -RUN yarn install && \ - yarn run build + --target x86_64-unknown-linux-musl # Now, we create the actual image @@ -52,9 +41,8 @@ RUN apk update && \ # Switch to non-root user USER fej:fej -# Copy binary & frontend over to final image -COPY --from=backend-builder --chown=fej:fej /app/output/bin /app/bin -COPY --from=frontend-builder --chown=fej:fej /app/dist /app/dist +# Copy binary over to final image +COPY --from=builder --chown=fej:fej /app/output/bin /app/bin # Embed config file inside container # The workdir is changed so that the config file is read properly diff --git a/fejctl b/fejctl index 57f7443..6f5c8a9 100755 --- a/fejctl +++ b/fejctl @@ -1,7 +1,6 @@ #!/usr/bin/env bash image='chewingbever/fej' -web_dir='web' # Small wrapper around the docker-compose command # @@ -99,12 +98,10 @@ function main() { # Building b | build ) dcr build --bin "$bin" && dc -- logs -f app ;; br | build-release ) dc -br build ;; - bf | build-frontend ) cd "$web_dir" && yarn run build ;; # Running r | run ) dcr run --bin "$bin" && dc -- logs -f app ;; rr | run-release ) dc -br -- up --build --detach && dc -r -- logs -f app ;; - rf | run-frontend ) dcr run --bin server && cd "$web_dir" && yarn run dev ;; s | stop ) dc down ;; sr | stop-release ) dc -r stop ;; diff --git a/src/server/main.rs b/src/server/main.rs index 2a5bd2f..0e84ff8 100644 --- a/src/server/main.rs +++ b/src/server/main.rs @@ -20,8 +20,6 @@ use rocket::fairing::{Fairing, Info, Kind}; use rocket::http::Header; use rocket::{Request, Response, Rocket}; use rocket_contrib::databases::diesel; -#[cfg(feature = "frontend")] -use rocket_contrib::serve::StaticFiles; pub struct CORS; @@ -62,21 +60,12 @@ fn run_db_migrations(rocket: Rocket) -> Result { } fn rocket() -> rocket::Rocket { - // This needs to be muted for the frontend feature - let mut rocket = rocket::ignite() + rocket::ignite() .attach(CORS) .attach(FejDbConn::fairing()) .attach(AdHoc::on_attach("Database Migrations", run_db_migrations)) - .mount("/api/ivago", routes::ivago()) // /api being hardcoded is temporary - .register(catchers![catchers::not_found]); - - // TODO make all of this not hard-coded - #[cfg(feature = "frontend")] - { - rocket = rocket.mount("/", StaticFiles::from("/app/dist")); - } - - rocket + .mount("/ivago", routes::ivago()) + .register(catchers![catchers::not_found]) } fn main() { diff --git a/web/.env b/web/.env deleted file mode 100644 index 18f38c1..0000000 --- a/web/.env +++ /dev/null @@ -1 +0,0 @@ -VITE_ENDPOINT=http://localhost:8000/api diff --git a/web/.env.production b/web/.env.production deleted file mode 100644 index cf6e652..0000000 --- a/web/.env.production +++ /dev/null @@ -1 +0,0 @@ -VITE_ENDPOINT=https://fej.roosens.me/api diff --git a/web/.gitignore b/web/.gitignore deleted file mode 100644 index 04459e4..0000000 --- a/web/.gitignore +++ /dev/null @@ -1,130 +0,0 @@ -# Created by https://www.toptal.com/developers/gitignore/api/node -# Edit at https://www.toptal.com/developers/gitignore?templates=node - -### Node ### -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional stylelint cache -.stylelintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test -.env*.local - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next - -# Nuxt.js build / generate output -.nuxt -dist - -# Storybook build outputs -.out -.storybook-out -storybook-static - -# rollup.js default build output -dist/ - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# Temporary folders -tmp/ -temp/ - -# End of https://www.toptal.com/developers/gitignore/api/node diff --git a/web/README.md b/web/README.md deleted file mode 100644 index a797a27..0000000 --- a/web/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Vue 3 + Typescript + Vite - -This template should help get you started developing with Vue 3 and Typescript in Vite. - -## 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 ` - - diff --git a/web/package.json b/web/package.json deleted file mode 100644 index ae1647d..0000000 --- a/web/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "fej-frontend", - "version": "0.0.0", - "scripts": { - "dev": "vite", - "build": "vue-tsc --noEmit && vite build", - "serve": "vite preview" - }, - "dependencies": { - "vue": "^3.0.5", - "vue-router": "^4.0.6" - }, - "devDependencies": { - "@vitejs/plugin-vue": "^1.2.1", - "@vue/compiler-sfc": "^3.0.5", - "typescript": "^4.1.3", - "vite": "^2.2.1", - "vue-tsc": "^0.0.25" - } -} diff --git a/web/public/favicon.ico b/web/public/favicon.ico deleted file mode 100644 index df36fcf..0000000 Binary files a/web/public/favicon.ico and /dev/null differ diff --git a/web/src/App.vue b/web/src/App.vue deleted file mode 100644 index ca4df88..0000000 --- a/web/src/App.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - - - diff --git a/web/src/api/ivago.ts b/web/src/api/ivago.ts deleted file mode 100644 index 662e531..0000000 --- a/web/src/api/ivago.ts +++ /dev/null @@ -1,32 +0,0 @@ -export class Street { - name: string; - city: string; - - constructor(name: string, city: string) { - this.name = name; - this.city = city; - } -} - -export class Ivago { - base_url: string; - - constructor(url: string) { - this.base_url = url; - } - - async search(search_term: string): Promise { - var r = await fetch(`${this.base_url}/ivago/search?` + new URLSearchParams({ - q: search_term, - })); - - if (!r.ok) { - return Promise.reject(); - } - - var json = await r.json(); - - return json.map((o: {name: string, city: string}) => new Street(o.name, o.city)); - } -} - diff --git a/web/src/assets/logo.png b/web/src/assets/logo.png deleted file mode 100644 index f3d2503..0000000 Binary files a/web/src/assets/logo.png and /dev/null differ diff --git a/web/src/components/HelloWorld.vue b/web/src/components/HelloWorld.vue deleted file mode 100644 index 12f05c8..0000000 --- a/web/src/components/HelloWorld.vue +++ /dev/null @@ -1,51 +0,0 @@ - - - - - diff --git a/web/src/components/Home.vue b/web/src/components/Home.vue deleted file mode 100644 index f5cc87a..0000000 --- a/web/src/components/Home.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/web/src/components/Ivago.vue b/web/src/components/Ivago.vue deleted file mode 100644 index 923f85c..0000000 --- a/web/src/components/Ivago.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - - - diff --git a/web/src/components/Nav.vue b/web/src/components/Nav.vue deleted file mode 100644 index fcf9c26..0000000 --- a/web/src/components/Nav.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - - - diff --git a/web/src/main.ts b/web/src/main.ts deleted file mode 100644 index af7463e..0000000 --- a/web/src/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createApp } from 'vue'; -import App from './App.vue'; -import router from './router'; - -const app = createApp(App) -app.use(router) - -app.mount('#app') diff --git a/web/src/router.ts b/web/src/router.ts deleted file mode 100644 index 2d7fa58..0000000 --- a/web/src/router.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { createWebHistory, createRouter } from "vue-router"; -import Home from './components/Home.vue'; -import Ivago from './components/Ivago.vue'; - -const routes = [ - { - path: "/", - component: Home, - }, - { - path: "/ivago", - component: Ivago, - }, -]; - -const router = createRouter({ - history: createWebHistory(), - routes, -}); - -export default router; diff --git a/web/src/shims-vue.d.ts b/web/src/shims-vue.d.ts deleted file mode 100644 index ac1ded7..0000000 --- a/web/src/shims-vue.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare module '*.vue' { - import { DefineComponent } from 'vue' - const component: DefineComponent<{}, {}, any> - export default component -} diff --git a/web/tsconfig.json b/web/tsconfig.json deleted file mode 100644 index e754e65..0000000 --- a/web/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "moduleResolution": "node", - "strict": true, - "jsx": "preserve", - "sourceMap": true, - "resolveJsonModule": true, - "esModuleInterop": true, - "lib": ["esnext", "dom"], - "types": ["vite/client"] - }, - "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"] -} diff --git a/web/vite.config.ts b/web/vite.config.ts deleted file mode 100644 index 315212d..0000000 --- a/web/vite.config.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { defineConfig } from 'vite' -import vue from '@vitejs/plugin-vue' - -// https://vitejs.dev/config/ -export default defineConfig({ - plugins: [vue()] -})