|
155 | 155 | RUN chmod +x /opt/csd-optimade/test-entrypoint.sh |
156 | 156 | CMD ["/opt/csd-optimade/test-entrypoint.sh"] |
157 | 157 |
|
| 158 | +FROM python-setup AS csd-optimade-server-with-csd-sidecar |
| 159 | + |
| 160 | +LABEL org.opencontainers.image.source="https://github.com/datalab-industries/csd-optimade" |
| 161 | +LABEL org.opencontainers.image.description="Server environment for the csd-optimade project" |
| 162 | + |
| 163 | +# Copy the CSD data into the serve image |
| 164 | +WORKDIR /opt/ccdc/ccdc-data |
| 165 | +COPY --from=compress-csd-data /opt/csd.tar.gz.gpg /opt/csd.tar.gz.gpg |
| 166 | + |
| 167 | +WORKDIR /opt/csd-optimade |
| 168 | +ENV CSD_DATA_DIRECTORY=/opt/ccdc/ccdc-data/csd |
| 169 | + |
| 170 | +# Copy the ingested CSD into the final image |
| 171 | +COPY --from=csd-ingester /opt/csd-optimade/csd-optimade.jsonl.gz.gpg /opt/csd-optimade/csd-optimade.jsonl.gz.gpg |
| 172 | + |
| 173 | +# Copy relevant csd-optimade build files only |
| 174 | +COPY LICENSE pyproject.toml uv.lock /opt/csd-optimade/ |
| 175 | +COPY src /opt/csd-optimade/src |
| 176 | + |
| 177 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 178 | + uv sync --locked --extra-index-url https://pip.ccdc.cam.ac.uk && \ |
| 179 | + # Remove unecessary mandatory deps from csd-python-api |
| 180 | + uv pip uninstall tensorflow tensorflow-estimator xgboost keras jax google-pasta opt-einsum nvidia-nccl-cu12 && \ |
| 181 | + # Remove duplicated csd-python-api install |
| 182 | + rm -rf /opt/csd-optimade/.venv/lib/python3.11/site-packages/lib/ccdc |
| 183 | + |
| 184 | +COPY <<-"EOF" /opt/csd-optimade/serve-entrypoint.sh |
| 185 | +#!/bin/bash |
| 186 | +set -e |
| 187 | + |
| 188 | +if [ -z "$CSD_ACTIVATION_KEY" ]; then |
| 189 | + echo "CSD_ACTIVATION_KEY not set" >&2 |
| 190 | + exit 1 |
| 191 | +fi |
| 192 | + |
| 193 | +mkdir -p /root/.config/CCDC |
| 194 | +echo -e "[licensing_v1]\nlicence_key=${CSD_ACTIVATION_KEY}" > /root/.config/CCDC/ApplicationServices.ini |
| 195 | +# For some reason, this folder must be present when reading sqlite, otherwise it assumes it cannot |
| 196 | +mkdir -p /opt/ccdc/ccdc-software |
| 197 | + |
| 198 | +echo "Decrypting CSD data..." |
| 199 | +time gpg --batch --passphrase ${CSD_ACTIVATION_KEY} --decrypt /opt/csd.tar.gz.gpg > /opt/csd.tar.gz |
| 200 | +time tar -xzf /opt/csd.tar.gz -C /opt/ccdc/ccdc-data |
| 201 | +echo "Decompressing CSD data..." |
| 202 | + |
| 203 | +echo "Decrypting and decompressing CSD OPTIMADE format..." |
| 204 | +gpg --batch --passphrase ${CSD_ACTIVATION_KEY} --decrypt /opt/csd-optimade/csd-optimade.jsonl.gz.gpg | gunzip > /opt/csd-optimade/csd-optimade.jsonl |
| 205 | + |
| 206 | +exec uv run --no-sync csd-serve --drop-first /opt/csd-optimade/csd-optimade.jsonl |
| 207 | +EOF |
| 208 | + |
| 209 | +RUN chmod +x /opt/csd-optimade/serve-entrypoint.sh |
| 210 | +CMD ["/opt/csd-optimade/serve-entrypoint.sh"] |
| 211 | + |
158 | 212 | FROM python-setup AS csd-optimade-server |
159 | 213 | LABEL org.opencontainers.image.source="https://github.com/datalab-industries/csd-optimade" |
160 | 214 | LABEL org.opencontainers.image.description="Production environment for the csd-optimade project" |
|
0 commit comments