Compare commits
5 commits
78185cd40d
...
02ef910880
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02ef910880 | ||
|
|
08364a1b5a | ||
|
|
91aff930d2 | ||
|
|
5d8b40a4c2 | ||
|
|
2f238e8d1c |
8 changed files with 67 additions and 65 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "huellas"
|
name = "huellas"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
||||||
22
Dockerfile
22
Dockerfile
|
|
@ -1,8 +1,10 @@
|
||||||
##### Builder ####
|
##### Builder ####
|
||||||
FROM rust:1.62-slim-bullseye as builder
|
FROM rust:1.64-alpine as builder
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y upgrade
|
RUN apk add --no-cache sqlite npm musl-dev
|
||||||
RUN apt-get -y install --no-install-recommends sqlite3 libsqlite3-dev npm && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
# Install Typescript
|
||||||
|
RUN npm install -g typescript
|
||||||
|
|
||||||
WORKDIR /usr/src
|
WORKDIR /usr/src
|
||||||
|
|
||||||
|
|
@ -18,9 +20,6 @@ WORKDIR /usr/src/huellas
|
||||||
# This is an empty build to get the dependencies cached.
|
# This is an empty build to get the dependencies cached.
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
# Install Typescript
|
|
||||||
RUN npm install -g typescript
|
|
||||||
|
|
||||||
# Now copy in the rest of the sources
|
# Now copy in the rest of the sources
|
||||||
COPY src /usr/src/huellas/src/
|
COPY src /usr/src/huellas/src/
|
||||||
COPY migrations /usr/src/huellas/migrations/
|
COPY migrations /usr/src/huellas/migrations/
|
||||||
|
|
@ -45,12 +44,15 @@ RUN npm install
|
||||||
# Transpile
|
# Transpile
|
||||||
RUN tsc
|
RUN tsc
|
||||||
|
|
||||||
|
# Delete the first line of jvascript ts-client
|
||||||
|
RUN sed -i '1d' build/client.js
|
||||||
|
|
||||||
################
|
################
|
||||||
##### Runtime
|
##### Runtime
|
||||||
FROM debian:bullseye-slim AS runtime
|
FROM alpine:3.16 AS Runtime
|
||||||
|
|
||||||
|
RUN apk add --no-cache sqlite
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y upgrade
|
|
||||||
RUN apt-get -y install --no-install-recommends sqlite3 && rm -rf /var/lib/apt/lists/*
|
|
||||||
# Copy application binary from builder image
|
# Copy application binary from builder image
|
||||||
COPY --from=builder /usr/src/huellas/target/release/huellas /usr/local/bin
|
COPY --from=builder /usr/src/huellas/target/release/huellas /usr/local/bin
|
||||||
# Copy Rocket.toml
|
# Copy Rocket.toml
|
||||||
|
|
@ -60,8 +62,6 @@ COPY Rocket.toml /usr/local/bin
|
||||||
COPY static /usr/local/bin/static/
|
COPY static /usr/local/bin/static/
|
||||||
# Copy javascript client
|
# Copy javascript client
|
||||||
COPY --from=builder /usr/src/huellas/ts-client/build/client.js /usr/local/bin/static
|
COPY --from=builder /usr/src/huellas/ts-client/build/client.js /usr/local/bin/static
|
||||||
# Delete the first line of jvascript ts-client
|
|
||||||
RUN sed -i '1d' /usr/local/bin/static/client.js
|
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
WORKDIR /usr/local/bin
|
WORKDIR /usr/local/bin
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
CREATE TABLE places (
|
CREATE TABLE places (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
name VARCHAR NOT NULL,
|
name VARCHAR NOT NULL,
|
||||||
address VARCHAR NOT NULL,
|
address VARCHAR NOT NULL,
|
||||||
open_hours VARCHAR NOT NULL,
|
open_hours VARCHAR NOT NULL,
|
||||||
icon VARCHAR NOT NULL,
|
icon VARCHAR NOT NULL,
|
||||||
description VARCHAR NOT NULL,
|
description VARCHAR NOT NULL,
|
||||||
longitude REAL NOT NULL,
|
longitude DOUBLE NOT NULL,
|
||||||
latitude REAL NOT NULL,
|
latitude DOUBLE NOT NULL,
|
||||||
active BOOLEAN NOT NULL DEFAULT TRUE
|
active BOOLEAN NOT NULL DEFAULT TRUE
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,35 @@
|
||||||
},
|
},
|
||||||
"query": "UPDATE places SET (name, address, open_hours, icon, description, longitude, latitude) = (?, ?, ?, ?, ?, ?, ?)"
|
"query": "UPDATE places SET (name, address, open_hours, icon, description, longitude, latitude) = (?, ?, ?, ?, ?, ?, ?)"
|
||||||
},
|
},
|
||||||
"8f8e9058b89c1f10360e08f8733c75e6ea2e8c15ff2c1e8a9f4a8ecd6e778642": {
|
"af66ec71413501f84c7f4cb0dd732c8ebfcd3da36a5f1177918c2277a8674c28": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"nullable": [],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "UPDATE places SET active = FALSE WHERE id = ?"
|
||||||
|
},
|
||||||
|
"e10f7e8f125a3f60338f6c35b195517d4304304599c75e4f26f071e2a09609dc": {
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"ordinal": 0,
|
||||||
|
"type_info": "Int64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nullable": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Right": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"query": "INSERT INTO places (name, address, open_hours, icon, description, longitude, latitude)VALUES (?, ?, ?, ?, ?, ?, ?)RETURNING id"
|
||||||
|
},
|
||||||
|
"fdc2eb1d98b93f2b61c756687f1a30edf2e4a74622e23b6b72a9509a9303385d": {
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
|
|
@ -44,12 +72,12 @@
|
||||||
"type_info": "Text"
|
"type_info": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "longitude",
|
"name": "longitude: f64",
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"type_info": "Float"
|
"type_info": "Float"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "latitude",
|
"name": "latitude: f64",
|
||||||
"ordinal": 7,
|
"ordinal": 7,
|
||||||
"type_info": "Float"
|
"type_info": "Float"
|
||||||
}
|
}
|
||||||
|
|
@ -68,34 +96,6 @@
|
||||||
"Right": 0
|
"Right": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"query": "SELECT id, name, address, open_hours, icon, description, longitude, latitude FROM places WHERE active = TRUE"
|
"query": "SELECT id, name, address, open_hours, icon, description,longitude as \"longitude: f64\", latitude as \"latitude: f64\" FROM places WHERE active = TRUE"
|
||||||
},
|
|
||||||
"af66ec71413501f84c7f4cb0dd732c8ebfcd3da36a5f1177918c2277a8674c28": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"nullable": [],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "UPDATE places SET active = FALSE WHERE id = ?"
|
|
||||||
},
|
|
||||||
"e10f7e8f125a3f60338f6c35b195517d4304304599c75e4f26f071e2a09609dc": {
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"name": "id",
|
|
||||||
"ordinal": 0,
|
|
||||||
"type_info": "Int64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"nullable": [
|
|
||||||
false
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Right": 7
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"query": "INSERT INTO places (name, address, open_hours, icon, description, longitude, latitude)VALUES (?, ?, ?, ?, ?, ?, ?)RETURNING id"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -9,6 +9,6 @@ pub struct Place {
|
||||||
pub open_hours: String,
|
pub open_hours: String,
|
||||||
pub icon: String,
|
pub icon: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub longitude: f32,
|
pub longitude: f64,
|
||||||
pub latitude: f32,
|
pub latitude: f64,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ struct Db(rocket_db_pools::sqlx::SqlitePool);
|
||||||
#[get("/places")]
|
#[get("/places")]
|
||||||
async fn get_places(mut db: Connection<Db>) -> Result<Json<Vec<Place>>> {
|
async fn get_places(mut db: Connection<Db>) -> Result<Json<Vec<Place>>> {
|
||||||
let places = rocket_db_pools::sqlx::query!(
|
let places = rocket_db_pools::sqlx::query!(
|
||||||
"SELECT id, name, address, open_hours, icon, description, longitude, latitude FROM places WHERE active = TRUE")
|
"SELECT id, name, address, open_hours, icon, description," +
|
||||||
|
r#"longitude as "longitude: f64", latitude as "latitude: f64" FROM places WHERE active = TRUE"#
|
||||||
|
)
|
||||||
.fetch(&mut *db)
|
.fetch(&mut *db)
|
||||||
.map_ok(|p| Place {
|
.map_ok(|p| Place {
|
||||||
id: Some(p.id),
|
id: Some(p.id),
|
||||||
|
|
@ -26,7 +28,7 @@ async fn get_places(mut db: Connection<Db>) -> Result<Json<Vec<Place>>> {
|
||||||
icon: p.icon,
|
icon: p.icon,
|
||||||
description: p.description,
|
description: p.description,
|
||||||
latitude: p.latitude,
|
latitude: p.latitude,
|
||||||
longitude: p.longitude
|
longitude: p.longitude,
|
||||||
})
|
})
|
||||||
.try_collect::<Vec<_>>()
|
.try_collect::<Vec<_>>()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<title>Huellas</title>
|
<title>👣 Huellas 🐾</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
|
||||||
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
|
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
|
||||||
|
|
@ -32,7 +32,6 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ async function setupMap(): Promise<void> {
|
||||||
const icons = new Map<string, L.Icon>();
|
const icons = new Map<string, L.Icon>();
|
||||||
icons.set('bar', new L.Icon({ iconUrl: 'icons/bar.svg' }));
|
icons.set('bar', new L.Icon({ iconUrl: 'icons/bar.svg' }));
|
||||||
icons.set('coffee', new L.Icon({ iconUrl: 'icons/coffee.svg' }));
|
icons.set('coffee', new L.Icon({ iconUrl: 'icons/coffee.svg' }));
|
||||||
|
icons.set('cinema', new L.Icon({ iconUrl: 'icons/film.svg' }));
|
||||||
icons.set('dining', new L.Icon({ iconUrl: 'icons/dining.svg' }));
|
icons.set('dining', new L.Icon({ iconUrl: 'icons/dining.svg' }));
|
||||||
icons.set('food', new L.Icon({ iconUrl: 'icons/food.svg' }));
|
icons.set('food', new L.Icon({ iconUrl: 'icons/food.svg' }));
|
||||||
icons.set('jazz', new L.Icon({ iconUrl: 'icons/saxophone.svg' }));
|
icons.set('jazz', new L.Icon({ iconUrl: 'icons/saxophone.svg' }));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue