J.
J.
Explore posts from servers
DDeno
Created by J. on 4/18/2025 in #help
how to persist data with deno kv when running a docker container?
I’m building a deno project using only the built-in deno kv. I know you can also use the self-hosted backend, but for now that's outside of my scope I want to containerize the app with docker using a single Dockerfile for simplicity what I need help with: - how to persist the local kv data across container runs - ensuring the non-root deno user can read from and write to the volume where data is stored currently I have something like:
FROM denoland/deno:alpine-2.2.10
WORKDIR /app
COPY deno.* .
RUN deno install
COPY . .
RUN deno cache server.ts
CMD ["run", "--allow-read", "--allow-write", "server.ts"]
FROM denoland/deno:alpine-2.2.10
WORKDIR /app
COPY deno.* .
RUN deno install
COPY . .
RUN deno cache server.ts
CMD ["run", "--allow-read", "--allow-write", "server.ts"]
docker build --tag <image-tag> .
docker build --tag <image-tag> .
docker run -it <image-tag> --mount source=<volume-name>,target=/data
docker run -it <image-tag> --mount source=<volume-name>,target=/data
This works, but I have to run the container with the root user (instead of passing the instruction USER deno). Any guidance or examples would be appreciated!
1 replies
TtRPC
Created by J. on 2/7/2024 in #ā“-help
Need Guidance Optimizing Multi-Select Typeahead
What your environment is: Node 18? Bun? pnpm / yarn / npm? - Bun v1.0.23 - Next.js v14.1.0 (app router) - tRPC v^10.45.0 - React Query v4 What's wrong: with complete and exact errors The current challenge involves the implementation of a multi-select typeahead feature. The objective is to disable the query when the user input's prefix matches any empty cached data. For instance, if a user enters "hello" and receives data [...], then enters "hellow" resulting in an empty data [], all subsequent queries prefixed with "hellow" should be disabled. What you have: any relevant code which you can share, better yet a full repo or stackblitz
// excerpted component code

// autocomplete
// (debounces input value and fetches autocomplete options)

const [inputValue, setInputValue] = useState("");
const [value, setValue] = useState<(string | QueryOutputItem)[]>([]);

const [platform, setPlatform] = useState<QueryInputPlatform>("šŸ‘€");

const utils = trpc.useUtils();
const debouncedInputValue = useDebounce(inputValue, 750);

const queryInput = {
platform,
query:
// intelligently determine whether to use cached or debounced input value
inputValue &&
(utils.autocomplete.getData({ platform, query: inputValue })
? inputValue
: debouncedInputValue)
};

const autocompleteQuery = trpc.autocomplete.useQuery(queryInput, {
enabled: !!queryInput.query
});
// excerpted component code

// autocomplete
// (debounces input value and fetches autocomplete options)

const [inputValue, setInputValue] = useState("");
const [value, setValue] = useState<(string | QueryOutputItem)[]>([]);

const [platform, setPlatform] = useState<QueryInputPlatform>("šŸ‘€");

const utils = trpc.useUtils();
const debouncedInputValue = useDebounce(inputValue, 750);

const queryInput = {
platform,
query:
// intelligently determine whether to use cached or debounced input value
inputValue &&
(utils.autocomplete.getData({ platform, query: inputValue })
? inputValue
: debouncedInputValue)
};

const autocompleteQuery = trpc.autocomplete.useQuery(queryInput, {
enabled: !!queryInput.query
});
1 replies