Initial docker file and stuff
This commit is contained in:
7
Makefile
7
Makefile
@@ -23,6 +23,13 @@ down: ## Stop Docker service containers
|
|||||||
connect: ## Connect to the Weather DB
|
connect: ## Connect to the Weather DB
|
||||||
docker exec -it ${DATABASE_CONTAINER} psql -U postgres
|
docker exec -it ${DATABASE_CONTAINER} psql -U postgres
|
||||||
|
|
||||||
|
clean: ## Cleanup Docker containers
|
||||||
|
docker compose down && \
|
||||||
|
docker image rm weather-ui || \
|
||||||
|
docker image rm weather-service || \
|
||||||
|
docker network rm weather-frontend || \
|
||||||
|
docker network rm weather-backend
|
||||||
|
|
||||||
clean-db: ## Remove database
|
clean-db: ## Remove database
|
||||||
docker exec -i ${DATABASE_CONTAINER} sh -c 'PGPASSWORD=${DATABASE_PASSWORD} psql -U ${DATABASE_USER} -d postgres -c "DROP DATABASE IF EXISTS \"${DATABASE_NAME}\";"'
|
docker exec -i ${DATABASE_CONTAINER} sh -c 'PGPASSWORD=${DATABASE_PASSWORD} psql -U ${DATABASE_USER} -d postgres -c "DROP DATABASE IF EXISTS \"${DATABASE_NAME}\";"'
|
||||||
docker exec -i ${DATABASE_CONTAINER} sh -c 'PGPASSWORD=${DATABASE_PASSWORD} psql -U ${DATABASE_USER} -d postgres -c "CREATE DATABASE \"${DATABASE_NAME}\";"' || true
|
docker exec -i ${DATABASE_CONTAINER} sh -c 'PGPASSWORD=${DATABASE_PASSWORD} psql -U ${DATABASE_USER} -d postgres -c "CREATE DATABASE \"${DATABASE_NAME}\";"' || true
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ services:
|
|||||||
- db_logs:/var/log
|
- db_logs:/var/log
|
||||||
ports:
|
ports:
|
||||||
- "${DATABASE_PORT}:5432"
|
- "${DATABASE_PORT}:5432"
|
||||||
|
networks:
|
||||||
|
- weather-backend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
service:
|
service:
|
||||||
@@ -23,11 +25,32 @@ services:
|
|||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
ports:
|
ports:
|
||||||
- "${SERVICE_PORT}:${SERVICE_PORT}"
|
- "${SERVICE_PORT}:5000"
|
||||||
build:
|
build:
|
||||||
context: service
|
context: service
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
|
networks:
|
||||||
|
- weather-frontend
|
||||||
|
- weather-backend
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
ui:
|
||||||
|
container_name: weather-ui
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=${NODE_ENV}
|
||||||
|
ports:
|
||||||
|
- ${UI_PORT}:3000
|
||||||
|
build:
|
||||||
|
context: ui
|
||||||
|
target: dev
|
||||||
|
command: npm run dev
|
||||||
|
depends_on:
|
||||||
|
- service
|
||||||
|
networks:
|
||||||
|
- weather-frontend
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
@@ -35,5 +58,5 @@ volumes:
|
|||||||
db_logs:
|
db_logs:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
default:
|
weather-frontend: {}
|
||||||
name: weather-backend
|
weather-backend: {}
|
||||||
|
|||||||
12
service/Dockerfile
Normal file
12
service/Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM rust:1.72.1-bookworm
|
||||||
|
|
||||||
|
WORKDIR /service
|
||||||
|
USER root
|
||||||
|
|
||||||
|
COPY migrations ./migrations
|
||||||
|
COPY src ./src
|
||||||
|
COPY airport-codes.json Cargo.toml diesel.toml ./
|
||||||
|
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
CMD ["./target/release/weather-service"]
|
||||||
@@ -45,7 +45,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
Some(listener) => server.listen(listener)?,
|
Some(listener) => server.listen(listener)?,
|
||||||
None => {
|
None => {
|
||||||
let host = std::env::var("SERVICE_HOST").expect("Please set host in .env");
|
let host = std::env::var("SERVICE_HOST").expect("Please set host in .env");
|
||||||
let port = std::env::var("SERVICE_PORT").expect("Please set port in .env");
|
// let port = std::env::var("SERVICE_PORT").expect("Please set port in .env");
|
||||||
|
let port = 5000;
|
||||||
debug!("Binding server to {}:{}", host, port);
|
debug!("Binding server to {}:{}", host, port);
|
||||||
server.bind(format!("{}:{}", host, port))?
|
server.bind(format!("{}:{}", host, port))?
|
||||||
}
|
}
|
||||||
|
|||||||
38
ui/Dockerfile
Normal file
38
ui/Dockerfile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Base
|
||||||
|
FROM node:18-alpine AS base
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
FROM base as deps
|
||||||
|
RUN apk add --no-cache libc6-compat
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Dev
|
||||||
|
FROM base AS dev
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Builder
|
||||||
|
FROM base AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Runner
|
||||||
|
FROM base AS runner
|
||||||
|
WORKDIR /app
|
||||||
|
RUN addgroup --system --gid 1001 nodejs && adduser --system --uid 1001 nextjs
|
||||||
|
COPY --from=builder /app/next.config.js ./
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
|
||||||
|
USER nextjs
|
||||||
|
EXPOSE 3000
|
||||||
|
ENV PORT 3000
|
||||||
|
ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
@@ -4,7 +4,19 @@ const nextConfig = {
|
|||||||
swcMinify: true,
|
swcMinify: true,
|
||||||
eslint: {
|
eslint: {
|
||||||
ignoreDuringBuilds: true
|
ignoreDuringBuilds: true
|
||||||
}
|
},
|
||||||
|
webpackDevMiddleware: (config) => {
|
||||||
|
config.watchOptions = {
|
||||||
|
poll: 1000,
|
||||||
|
aggregateTimeout: 300
|
||||||
|
};
|
||||||
|
return config;
|
||||||
|
},
|
||||||
|
publicRuntimeConfig: {
|
||||||
|
// remove private variables from processEnv
|
||||||
|
processEnv: Object.fromEntries(Object.entries(process.env).filter(([key]) => key.includes('NEXT_PUBLIC_')))
|
||||||
|
},
|
||||||
|
output: 'standalone'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = nextConfig;
|
module.exports = nextConfig;
|
||||||
|
|||||||
5222
ui/package-lock.json
generated
Normal file
5222
ui/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,6 @@ export default function MapTiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function iconSize() {
|
function iconSize() {
|
||||||
console.log('zoom', zoomLevel);
|
|
||||||
if (zoomLevel <= 4) {
|
if (zoomLevel <= 4) {
|
||||||
return 'text-xs';
|
return 'text-xs';
|
||||||
} else if (zoomLevel <= 5) {
|
} else if (zoomLevel <= 5) {
|
||||||
|
|||||||
Reference in New Issue
Block a user