Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom data directory not working #267

Open
ks-dipeshc opened this issue Jun 22, 2024 · 4 comments
Open

Custom data directory not working #267

ks-dipeshc opened this issue Jun 22, 2024 · 4 comments

Comments

@ks-dipeshc
Copy link

ks-dipeshc commented Jun 22, 2024

I am using 1.4.10 version in my NestJs (node) project.

I run my project using the docker.

When i execute update command inside docker and restart the container, the data will lose.

So I read the documentation they mention here to use env variable. https://github.com/geoip-lite/node-geoip?tab=readme-ov-file#environment-variables
but Some how it is not working. they always use directory of the the node_modules.

Is that something I missed?
Thank you.

@bluesmoon
Copy link
Collaborator

If you are installing inside docker, your data upgrades will be ephemeral - you will need to download them every time you start the container.

A better option is to create a docker volume that has the data files. Whenever you upgrade the files, you commit the volume to create a new image. This only needs to be done once a month. You can mount this volume into other docker containers as read-only to be used as needed.

@ks-dipeshc
Copy link
Author

A better option is to create a docker volume that has the data files. Whenever you upgrade the files, you commit the volume to create a new image. This only needs to be done once a month. You can mount this volume into other docker containers as read-only to be used as needed.

@bluesmoon Thanks.
How Can I inform geoip-lite package to use that volume for data instead of node_modules/geoip-lite/data/? As I mention env variable is not helping.

@bluesmoon
Copy link
Collaborator

Mount the volume into that location

@ks-dipeshc
Copy link
Author

Mount the volume into that location

Can you please elaborate the steps. As i am new in Docker.

FROM node:18.16-alpine AS development
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

RUN npm explore geoip-lite -- npm run-script updatedb license_key=mykey

CMD [ "node", "dist/main.js" ]

My yml file for project

version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: geoip2
    ports:
      - '3001:3000'
    volumes:
      - .:/app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants