fix: update Dockerfile and weather service configuration

- Added 'libpq-dev' to the packages installed in the Dockerfile
- Updated the base_uri in WeatherService to use 'dig' for safer access

These changes improve the Docker environment by ensuring that
necessary PostgreSQL development headers are available during
installation. The weather service now safely accesses the
URI from the credentials, reducing the risk of errors when
fetching nested configuration data.
This commit is contained in:
songtianlun 2025-01-22 17:07:04 +08:00
parent 2d81dd91e7
commit b5c40f2e13
2 changed files with 2 additions and 2 deletions

View File

@ -30,7 +30,7 @@ FROM base AS build
# Install packages needed to build gems and node modules # Install packages needed to build gems and node modules
RUN apt-get update -qq && \ RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git node-gyp pkg-config python-is-python3 && \ apt-get install --no-install-recommends -y build-essential git node-gyp pkg-config python-is-python3 libpq-dev && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install JavaScript dependencies # Install JavaScript dependencies

View File

@ -1,7 +1,7 @@
# app/services/weather_service.rb # app/services/weather_service.rb
class WeatherService class WeatherService
include HTTParty include HTTParty
base_uri Rails.application.credentials.qweather.uri base_uri Rails.application.credentials.dig(:qweather, :uri)
def initialize def initialize
@api_key = Rails.application.credentials.qweather.token @api_key = Rails.application.credentials.qweather.token