Skip to content

Latest commit

 

History

History
127 lines (92 loc) · 2.2 KB

05.Setting_Up_the_Foundation_Docker_Images_and_Registry.md

File metadata and controls

127 lines (92 loc) · 2.2 KB

Setting Up the Foundation: Docker Images and Registry

Docker Images

cat <<EOF >$HOME/RestQR/menu/Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
EOF
cat <<EOF >$HOME/RestQR/qr/Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]
EOF
mkdir -p $HOME/RestQR/postgresql && \
cat <<EOF >$HOME/RestQR/postgresql/Dockerfile
FROM bitnami/postgresql:17.4.0-debian-12-r1
EOF
# Build the menu service image
docker build \
    -t menu-service \
    $HOME/RestQR/menu

# Build the qr service image    
docker build \
    -t qr-service \
    $HOME/RestQR/qr

# Build the menu-postgresql image
docker build \
    -t menu-postgresql \
    $HOME/RestQR/postgresql
docker images

Docker Registry

GITLAB_USERNAME=$(glab api /user | jq -r .username)
cat <<EOF >>~/.bashrc && source ~/.bashrc
export GITLAB_USERNAME=$GITLAB_USERNAME
EOF
docker login registry.gitlab.com \
    -u $GITLAB_USERNAME \
    --password-stdin <<< $GITLAB_API_TOKEN
cat <<EOF >>~/.bashrc && source ~/.bashrc
export GITLAB_REGISTRY_URL="registry.gitlab.com/${GITLAB_GROUP,,}/${GITLAB_PROJECT,,}"
EOF
# Tag the menu service image
docker tag menu-service \
    $GITLAB_REGISTRY_URL/menu-service:v0.1.0

# Tag the qr service image
docker tag qr-service \
    $GITLAB_REGISTRY_URL/qr-service:v0.1.0

# Tag the menu-postgres image
docker tag menu-postgresql \
    $GITLAB_REGISTRY_URL/menu-postgresql:v0.1.0
# Push the menu service image
docker push \
    $GITLAB_REGISTRY_URL/menu-service:v0.1.0

# Push the qr service image
docker push \
    $GITLAB_REGISTRY_URL/qr-service:v0.1.0

# Push the menu-postgresql image
docker push \
    $GITLAB_REGISTRY_URL/menu-postgresql:v0.1.0
# Export the project ID
project_id=$(glab api /projects/$GITLAB_GROUP%2F$GITLAB_PROJECT | jq -r .id)

# List the images in the GitLab Container Registry for the project with the ID $project_id
glab api /projects/$project_id/registry/repositories | jq -r '.[] | .path'