Skip to content

Commit 0c860ec

Browse files
authored
[ENHANCEMENTE]argilla-server: unify credentials for both docker images (#5324)
# Description <!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. --> This PR reviews and unifies the credentials setup for both docker images. With changes on this PR, the following env variables are available for both images: - `USERNAME`: the owner username (Default: "") - `PASSWORD`: the owner password (Default: "") - `API_KEY`: the owner API KEY (Default: "") - `REINDEX_DATASETS`: launch reindex datasets on server server startup (Default=0) TODO: - [x] Add defaults in the [`docker-compose.yaml`](https://github.com/argilla-io/argilla/pull/5315/files#diff-e7d583fa0f5bfdf69891c1714df0e8dd48be872d9c5efe1f3128b6d3d12f49a2) file with the following values: ```yaml USERNAME: argilla PASSWORD: 12345678 API_KEY: argilla.apikey ``` -> Done [here](1480e16) - [x] Add description in [the server configuration](https://github.com/argilla-io/argilla/pull/5291/files#diff-4b8728c9f3074b2a2209fb900e51dfd3a9ad058f221c8ae244567fd8786da27dR119) -> Done [here](https://github.com/argilla-io/argilla/pull/5291/files#diff-4b8728c9f3074b2a2209fb900e51dfd3a9ad058f221c8ae244567fd8786da27dR115) **Type of change** <!-- Please delete options that are not relevant. Remember to title the PR according to the type of change --> - Improvement (change adding some improvement to an existing functionality) **How Has This Been Tested** <!-- Please add some reference about how your feature has been tested. --> **Checklist** <!-- Please go over the list and make sure you've taken everything into account --> - I added relevant documentation - I followed the style guidelines of this project - I did a self-review of my code - I made corresponding changes to the documentation - I confirm My changes generate no new warnings - I have added tests that prove my fix is effective or that my feature works - I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)
1 parent 1544864 commit 0c860ec

File tree

4 files changed

+24
-36
lines changed

4 files changed

+24
-36
lines changed

argilla-server/docker/argilla-hf-spaces/Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ USER root
77

88
# Copy Argilla distribution files
99
COPY scripts/start.sh /home/argilla
10-
COPY scripts/start_argilla_server.sh /home/argilla
1110
COPY Procfile /home/argilla
1211
COPY requirements.txt /packages/requirements.txt
1312

@@ -52,9 +51,7 @@ USER argilla
5251
ENV ELASTIC_CONTAINER=true
5352
ENV ES_JAVA_OPTS="-Xms1g -Xmx1g"
5453

55-
ENV USERNAME=""
56-
ENV PASSWORD=""
57-
5854
ENV ARGILLA_HOME_PATH=/data/argilla
55+
ENV REINDEX_DATASETS=1
5956

6057
CMD ["/bin/bash", "start.sh"]

argilla-server/docker/argilla-hf-spaces/scripts/start_argilla_server.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

argilla-server/docker/server/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ RUN apt-get update && \
1717
FROM python:3.10.12-slim
1818

1919
# Environment Variables
20+
ENV USERNAME=""
21+
ENV PASSWORD=""
22+
ENV API_KEY=""
23+
## Argilla home path
2024
ENV ARGILLA_HOME_PATH=/var/lib/argilla
21-
ENV DEFAULT_USER_ENABLED=true
22-
ENV DEFAULT_USER_PASSWORD=1234
23-
ENV DEFAULT_USER_API_KEY=argilla.apikey
24-
ENV USERS_DB=/config/.users.yml
25+
## Uvicorn defaults
2526
ENV UVICORN_PORT=6900
2627

2728
RUN useradd -ms /bin/bash argilla

argilla-server/docker/server/scripts/start_argilla_server.sh

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,24 @@ set -e
44
# Run database migrations
55
python -m argilla_server database migrate
66

7-
# Create default user
8-
if [ "$DEFAULT_USER_ENABLED" = "true" ] || [ "$DEFAULT_USER_ENABLED" = "1" ]; then
9-
python -m argilla_server database users create_default --password $DEFAULT_USER_PASSWORD --api-key $DEFAULT_USER_API_KEY
7+
if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]; then
8+
echo "Creating owner user with username ${USERNAME}"
9+
if [ -n "$API_KEY" ]; then
10+
python -m argilla_server database users create \
11+
--first-name "$USERNAME" \
12+
--username "$USERNAME" \
13+
--password "$PASSWORD" \
14+
--api-key "$API_KEY" \
15+
--role owner
16+
else
17+
python -m argilla_server database users create \
18+
--first-name "$USERNAME" \
19+
--username "$USERNAME" \
20+
--password "$PASSWORD" \
21+
--role owner
22+
fi
23+
else
24+
echo "No username and password was provided. Skipping user creation"
1025
fi
1126

1227
# Reindexing data into search engine

0 commit comments

Comments
 (0)