Certification disponible
Cours
2 hr
135K
mkdir hello-world-app
cd hello-world-app
const http = require('http');
const requestListener = (req, res) => {
res.writeHead(200);
res.end('Hello, Cloud Run!');
};
const server = http.createServer(requestListener);
server.listen(8080, () => {
console.log('Server is running on port 8080');
});
{
"name": "hello-world-app",
"version": "1.0.0",
"main": "index.js",
"dependencies": {}
}
# Use the official Node.js image as a base
FROM node:16-alpine
# Set the working directory inside the container
WORKDIR /usr/src/app
# Copy package.json and install dependencies (if any)
COPY package*.json ./
# Copy the rest of the application code
COPY . .
# Expose port 8080 for Cloud Run
EXPOSE 8080
# Start the app
CMD ["node", "index.js"]
docker build -t gcr.io/your-project-id/hello-world-app .
docker run -p 8080:8080 gcr.io/your-project-id/hello-world-app
gcloud services enable artifactregistry.googleapis.com
gcloud artifacts repositories create hello-world-repo \
--repository-format=docker \
--location=us-central1
gcloud auth configure-docker us-central1-docker.pkg.dev
docker tag gcr.io/your-project-id/hello-world-app us-central1-docker.pkg.dev/your-project-id/hello-world-repo/hello-world-app
docker push us-central1-docker.pkg.dev/your-project-id/hello-world-repo/hello-world-app
gcloud run deploy hello-world-app \
--image us-central1-docker.pkg.dev/your-project-id/hello-world-repo/hello-world-app \
--platform managed \
--region us-central1 \
--allow-unauthenticated
gcloud run services delete hello-world-app --region us-central1
gcloud artifacts docker images list us-central1-docker.pkg.dev/your-project-id/hello-world-repo
gcloud artifacts docker images delete us-central1-docker.pkg.dev/your-project-id/hello-world-repo/hello-world-app --delete-tags
gcloud artifacts repositories delete hello-world-repo --location=us-central1
gcloud projects delete your-project-id
gcloud run deploy hello-world-app \
--source . \
--region us-central1 \
--allow-unauthenticated
CPU | ||
Ingénieur logiciel senior, rédacteur technique et conseiller avec une formation en physique. Nous nous engageons à aider les jeunes entreprises à atteindre leur potentiel et à rendre des concepts complexes accessibles à tous.
Cours
Cours
Cours