Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using Docker for your Applications

Using Docker for your Applications

Sheharyar Naseer

March 31, 2024
Tweet

More Decks by Sheharyar Naseer

Other Decks in Technology

Transcript

  1. Technology advisor & consultant for startups, and Manager at Google

    Developers Group Find me online @sheharyarn Sheharyar Naseer
  2. Background • Indie Nomad Software Architect • 13+ years of

    polyglot experience, focus on Web & Cloud • StackOverflow: 70,000+ score (Top 5 in Pakistan) • Author / Contributor of multiple famous libraries & tools • Featured on popular developer communities
  3. Outline Beyond Local Docker: What, Why & How Deploying to

    the Cloud Live Demo Learning Resources Q&A
  4. Beyond Local • Local development is the first step •

    More complexity requires more moving parts • Different aspects: • Implementing a dedicated backend • Scaling existing backend systems • Development reliability across teams
  5. Adding a Backend • Gemini and other APIs are backends

    too • So Why? • Offload complexity • Data syncing • Validations and Pre- and Post-processing • Security concerns
  6. Technology Verticals • Web & Mobile • ML / AI

    • Distributed Systems • Internet of Things • Mixed Reality CLOUD
  7. Scaling Existing Backends • Even more complexity • Increasing performance

    • Different microservices • Splitting responsibilities • Single endpoint vs multiple
  8. Team Dev Environments • Multiple devs working on the same

    codebase • "But works on my machine!" • Consistent development environment • Reproducible issues • Focus on development
  9. Docker is the top-used tool amongst all Professional developers “

     StackOverflow Developer Survey 2023  2019 2020 2021 2022 69% 49% 39% 35%
  10. Docker – The What • "An open-source platform for containerizing

    applications and environments" • Docker Image: • Set of commands describing how to run your app • Write once, run anywhere • The "ABCs" of your Cloud journey
  11. Docker – The Why • Imagine buying a new computer

    • You set it up and install apps • Run system updates, etc. • Software: • Repeat steps on every fresh deploy • Manually run updates • Fix broken steps
  12. Docker – The Why • Ship code faster • Standardize

    operations • Save money • Simplify security • Run and deploy anywhere
  13. Docker – The How • Install Docker • Create a

    "Dockerfile" • Write steps to run app • Run it!
  14. Example – Java App FROM openjdk:8-jdk-alpine # Copy code WORKDIR

    /app COPY . . # Compile app RUN ./gradlew build RUN mv ./build/libs/*.jar ./app.jar # Start app CMD ["java", "-jar", "/app/app.jar"]
  15. Example – Python App FROM python:3 # Set the app

    directory WORKDIR /app COPY . . # Install dependencies RUN pip3 install -r requirements.txt # Start app EXPOSE 5000 CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"]
  16. CloudUp.dev • Dockerfile Generator • Maintained by GDG Lahore •

    Supports common languages • Guided steps https://cloudup.dev/
  17. Build and Run # Run Java App docker build -t

    demo-java:v1 . docker run -it -p 8080:8080 demo-java:v1 # Run Python App docker build -t demo-python:v1 . docker run -it -p 5000:5000 demo-python:v1
  18. Infrastructure Providers • Google Cloud Platform • Amazon Web Services

    • Heroku • DigitalOcean • Fly.io • and many more...
  19. GCP + Docker • World-class support for Docker • Cloud-native

    tooling • Build, Deploy and Run any Docker image • Simple experience
  20. Save to Cloud Registry # Setup gcloud login gcloud config

    project set ${PROJECT_ID} # Build and Save Image gcloud builds submit \ --tag=gcr.io/${PROJECT_ID}/my-app:v1 .
  21. Deploy with Cloud Run • Instantly deploy any container •

    Very simple UI • Deploy previously uploaded
  22. Helpful Resources KEEP LEARNING Docker • Official Docs: docs.docker.com •

    Friendly Guides: vsupalov.com/docker • Dockerfile Generator: cloudup.dev Google Cloud • GCP Container Registry: gcr.io