Make sure you have the Google Cloud SDK installed on your local machine. You can download it from Google Cloud SDK.
Open a terminal and run the following command to authenticate your account:
gcloud auth login
Follow the instructions in your browser to complete the authentication process.
If you have multiple projects, set the one you want to use:
gcloud config set project projectID
Ensure that the Container Registry API is enabled. You can do this in the Google Cloud Console, or use the following command:
gcloud services enable containerregistry.googleapis.com
Navigate to the directory containing your Dockerfile and API code, then build and tag your Docker image:
docker build -t gcr.io/projectID/emojiapi:v1 .
Replace projectID, emojiapi, and v1 with your actual project ID, image name, and tag.
Now, push your Docker image to Google Container Registry:
docker push gcr.io/projectID/emojiapi:v1
If you want to deploy your Dockerized API using Google Cloud Run, you can use the following command:
gcloud run deploy emojiapi-service --image gcr.io/projectID/emojiapi:v1 --platform managed
Replace emojiapi-service with the desired service name.
That's it! Your Dockerized API is now uploaded to Google Cloud. Remember to replace placeholder values with your actual project details, image name, and tag. If you encounter any issues, refer to the Google Cloud documentation for more detailed information.
Error on Step 6 - unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials.
Make sure you are authenticated with your Google Cloud account. Run the following command to log in:
gcloud auth login
Follow the instructions in your browser to complete the authentication process.
Ensure you have set the correct Google Cloud project:
gcloud config set project projectID
Run the following command to authenticate Docker with your Google Container Registry:
gcloud auth configure-docker
This command configures Docker to use your Google Cloud credentials when pushing images.
Now, try pushing your Docker image again:
docker push gcr.io/projectID/emojiapi:v1