s3: automatically create a bucket on startup

This commit is contained in:
Tomasz Dłuski
2021-12-03 22:10:59 +01:00
parent 4c4449110e
commit 6e798644da
4 changed files with 20 additions and 9 deletions

4
.env
View File

@@ -1,5 +1,5 @@
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY AWS_SECRET_ACCESS_KEY=sample_key
AWS_REGION=us-east-1 AWS_REGION=us-east-1
AWS_BUCKET_NAME=mlflow AWS_BUCKET_NAME=mlflow
MYSQL_DATABASE=mlflow MYSQL_DATABASE=mlflow

View File

@@ -1,9 +1,8 @@
version: "3.9" version: "3.9"
services: services:
s3: s3:
image: minio/minio:RELEASE.2021-08-25T00-41-18Z.hotfix.55efceab5 image: minio/minio:RELEASE.2021-11-24T23-19-33Z
restart: unless-stopped restart: unless-stopped
container_name: aws-s3
ports: ports:
- "9000:9000" - "9000:9000"
- "9001:9001" - "9001:9001"
@@ -48,11 +47,23 @@ services:
networks: networks:
- public - public
- internal - internal
entrypoint: ./wait-for-it.sh db:3306 -t 90 -- mlflow server --backend-store-uri mysql+pymysql://${MYSQL_USER}:${MYSQL_PASSWORD}@db:3306/${MYSQL_DATABASE} --default-artifact-root s3://${AWS_BUCKET_NAME}/ -h 0.0.0.0 entrypoint: bash ./wait-for-it.sh db:3306 -t 90 -- mlflow server --backend-store-uri mysql+pymysql://${MYSQL_USER}:${MYSQL_PASSWORD}@db:3306/${MYSQL_DATABASE} --default-artifact-root s3://${AWS_BUCKET_NAME}/ -h 0.0.0.0
create_s3_buckets:
image: minio/mc
depends_on:
- "s3"
entrypoint: >
/bin/sh -c "
until (/usr/bin/mc alias set minio http://s3:9000 '${AWS_ACCESS_KEY_ID}' '${AWS_SECRET_ACCESS_KEY}') do echo '...waiting...' && sleep 1; done;
/usr/bin/mc mb minio/mlflow;
exit 0;
"
networks:
- internal
networks: networks:
internal: internal:
public: public:
driver: bridge driver: bridge
volumes: volumes:
db_volume: db_volume:
minio_volume: minio_volume:

View File

@@ -1,10 +1,10 @@
FROM continuumio/miniconda3:latest FROM continuumio/miniconda3:latest
RUN pip install mlflow boto3 pymysql
ADD . /app ADD . /app
WORKDIR /app WORKDIR /app
COPY wait-for-it.sh wait-for-it.sh COPY wait-for-it.sh wait-for-it.sh
RUN chmod +x wait-for-it.sh RUN chmod +x wait-for-it.sh
RUN pip install mlflow boto3 pymysql

View File

@@ -179,4 +179,4 @@ if [[ $WAITFORIT_CLI != "" ]]; then
exec "${WAITFORIT_CLI[@]}" exec "${WAITFORIT_CLI[@]}"
else else
exit $WAITFORIT_RESULT exit $WAITFORIT_RESULT
fi fi