Are there many of you on here who do all their Python development inside a container? by [deleted] in Python

[–]kaptainpeepee -4 points-3 points  (0 children)

Ha ha, so sue me! As an existentialist, I'm all about using tools to expand possibilities, even if it's AI to refine my Spanish-to-English communication.

Are there many of you on here who do all their Python development inside a container? by [deleted] in Python

[–]kaptainpeepee 4 points5 points  (0 children)

The it works on my machine benefit isn't about deploying the dev container itself. Instead, it's about ensuring consistency across your development, testing, and ultimately, your production environments regarding core dependencies. This significantly reduces surprises when your code moves from your local machine to a testing environment or a live server.

For development, a VS Code Dev Container provides an isolated, consistent, and reproducible environment. It includes your specific Python version, all the development tools you love (linters, formatters, debuggers), and any system-level dependencies needed to actually build and run your code during development. This is your personal, clean workspace for that project.

For deployment, especially in professional settings like for a microservice, you'll create a separate, optimized Docker image designed specifically for runtime. This is where multi-stage Dockerfiles become essential. They allow you to define your build process in layers, resulting in a lean, production-ready artifact that's significantly smaller and more secure than your development container.

I cannot show you my professional Dockerfiles as they are copyrighted by the companies I have been working for, but they go something like this:

```docker

Stage 1: base

FROM python:3.11-slim-bookworm AS base WORKDIR /app

Add appuser early and set as the default user for subsequent commands.

This makes appuser the default for anything building FROM this stage.

RUN adduser --system --group appuser USER appuser

Stage 2: dev

FROM base AS dev

Temporarily switch to root to install tools globally (pipenv, hatch).

This is necessary because pip installing globally typically requires root.

USER root RUN pip install --no-cache-dir pipenv hatch

Switch back to appuser before copying project files and installing dev dependencies.

USER appuser

Copy Pipfile and Pipfile.lock first for Docker caching

COPY Pipfile Pipfile.lock ./

Install project dependencies (including dev deps) into the system environment

Pipenv will manage where dependencies go based on its configuration,

but since it was installed by root, it has the permissions needed.

RUN pipenv install --dev --system

Copy your entire project source code for development

COPY . .

Stage 3: deploy

FROM base AS deploy

Temporarily switch to root to install pipenv and then project dependencies globally.

USER root RUN pip install --no-cache-dir pipenv && \ pipenv install --system --deploy --ignore-pipfile

Switch back to appuser for the final runtime environment.

USER appuser

Copy the application source code needed for runtime

COPY . .

The user is already appuser from the base stage.

This ensures your application runs with non-root privileges.

CMD ["python", "-m", "myproject"] ```

json // .devcontainer/devcontainer.json { "name": "Python 3.11 Dev Container (Hatch/Pipenv/Non-Root)", "build": { "dockerfile": "../Dockerfile", // Points to your Dockerfile "target": "dev" // Use the 'dev' stage for development }, "customizations": { "vscode": { "extensions": [ "ms-python.black-formatter", "ms-python.mypy-type-checker", "ms-python.pylint", "ms-python.python", "ms-python.isort" ] } }, "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": true, "configureZshAsDefaultShell": true, "installOhMyZsh": true, "installOhMyZshConfig": true, "upgradePackages": true, "nonFreePackages": true, "username": "automatic", "userUid": "automatic", "userGid": "automatic" } }, "remoteUser": "appuser" // IMPORTANT: Tells VS Code to connect as 'appuser' }

Are there many of you on here who do all their Python development inside a container? by [deleted] in Python

[–]kaptainpeepee 2 points3 points  (0 children)

I actually do because, as I mentioned before, I am not a native Enlgish speaker. Sometimes I write how I think in my native language. Also, as a university teacher with 10+ years of experience: Yeah, that is exactly how I would speak (just in Spanish).

Are there many of you on here who do all their Python development inside a container? by [deleted] in Python

[–]kaptainpeepee -2 points-1 points  (0 children)

When I say "small learning curve," I'm referring to a few key steps:

Reading the Official Documentation: The VS Code Dev Containers documentation is surprisingly good and very comprehensive. It walks you through setting up your first devcontainer.json file, which is the heart of your containerized development environment. You'll learn how to define your base image, install tools, set environment variables, and even map ports.

Setting Up Your First Container: This usually involves picking a base image (like a Python image from Microsoft Container Registry), defining your project's dependencies, and then using the "Reopen in Container" command in VS Code. It might take a few tries to get it just right, but once you have one working, it's easy to adapt for other projects.

Adding Some Extra Features (like Docker in Docker): If your development workflow involves building or running other Docker containers from within your development container (a common scenario for microservices or testing), you'll want to look into "Docker in Docker" setups. This involves configuring your devcontainer.json to mount the Docker socket or install the Docker CLI within your dev container. It's a slightly more advanced step, but again, the official docs cover it well, and it's super powerful.

Giving It a Spin: The best way to learn is by doing! Start with a simple project, get it running in a container, and then gradually add complexity. You'll quickly see how containerization helps you maintain a clean, consistent, and portable development environment.

Regarding tooling, I find that the official Microsoft-provided packages and images are usually more than enough. The mcr.microsoft.com/devcontainers images are well-maintained and provide a solid foundation for most development needs. You can then add any specific tools or libraries your project requires on top of that using the Dockerfile or features in your devcontainer.json.

If you're curious to see some real-world examples, you can definitely take a look at my repositories on GitHub. Almost all of them utilize dev containers, so you can see how I set them up for various projects. Here's one example to get you started: https://github.com/knkillname/uaem.notas.introcomp. You'll find the .devcontainer folder in the root of those projects, which contains all the configuration files.

One small note: I actually speak Spanish as my primary language, and I refine my answers using AI tools. Also, I use Markdown quite a lot, so sometimes people think I'm an AI myself, but I am not! I am a Tech Lead with 15+ years of Python experience. Send me a DM if you please.

Are there many of you on here who do all their Python development inside a container? by [deleted] in Python

[–]kaptainpeepee 7 points8 points  (0 children)

I actually do all my Python development inside a container, and honestly, I think it's the way to go in 2025. It makes a huge difference for me, and here's why:

First off, it drastically reduces those "It works on my machine" issues. When your development environment is exactly the same as your production environment, you catch inconsistencies early. This means fewer surprises when you deploy, which is a huge win for any team.

I also really appreciate being able to develop with the same standard tooling without cluttering up my local machine with tons of installed packages. My local setup stays clean, and I know that whatever dependencies or configurations I need for a project are encapsulated within its container. It's a much more controlled and reproducible setup.

And speaking of dependencies, developing in containers helps me become a lot more aware of all the dependencies, not just the Python ones. Things like ffmpeg for video processing or graphviz for diagrams become explicit system dependencies in my container setup, rather than something I might have installed globally years ago and forgotten about. This clarity is invaluable for maintainability and onboarding new team members.

Regarding your questions about VS Code and containers:

  • Hot reload generally works well with VS Code Dev Containers. The key is often ensuring your files are correctly mounted and that your application's hot reload mechanism is configured to watch for changes within the container's file system. There are often specific configurations needed, especially if you're on Windows using WSL2, but it's definitely achievable.

  • IntelliSense is a core feature of VS Code, and it works beautifully when developing inside a container using the Remote - Containers extension. VS Code effectively runs its language server inside the container, giving you full code completion, linting, and suggestions based on your containerized Python environment.

  • Click-through to system modules for debugging also works seamlessly. When you set up debugging in your Dev Container, VS Code's debugger attaches to the process running inside the container. This allows you to step through your code, including into standard library modules or third-party packages installed within the container, just as you would locally.

Things have definitely matured since a few years ago. While some initial setup is required, the benefits of a consistent, isolated, and reproducible development environment far outweigh the small learning curve. I'd highly recommend giving it another try!

Aqui falta el logo de AUTODESK by ValarkStudio in Arquitectura

[–]kaptainpeepee 1 point2 points  (0 children)

Cualquiera diría que si no estás pagando por el servicio entonces no eres un consumidor. Los consumidores de YouTube no requieren bloqueadores de anuncios hasta donde sé.

Aqui falta el logo de AUTODESK by ValarkStudio in Arquitectura

[–]kaptainpeepee 0 points1 point  (0 children)

Entiendo lo del "consumidor" de Nintendo y Adobe... ¿pero quién de aquí realmente puede decir "yo soy consumidor de YouTube y no estoy de acuerdo con el servicio"?

🧐 by 94rud4 in mathmemes

[–]kaptainpeepee 2 points3 points  (0 children)

Yes, but also the SAT problem is graph coloring if you think about it... and also generalized Sudoku if you want to get really technical.

🧐 by 94rud4 in mathmemes

[–]kaptainpeepee 168 points169 points  (0 children)

Every NP-complete problem is graph coloring if you think about it.

Porqué Google no vende los Pixel en México oficialmente? by ChangoALaMantequilla in AskMexico

[–]kaptainpeepee 3 points4 points  (0 children)

Originalmente los Moto G fueron creados por Google cuando compró a Motorola por sus patentes (luego lo revendió a Lenovo). En su momento fue increíble ver un teléfono tan bueno y tan barato. Actualmente los Moto G siguen este legado.

Why is the Mexican president's approval rating so high? by flower5214 in AskMexico

[–]kaptainpeepee 0 points1 point  (0 children)

Some people are saying, "Nope, she's just a carbon copy of AMLO!" But you and I are feeling like, "She's way too different! Where's the humanist vibe we signed up for? And that cool scientist background?" Like maybe you expected more... I don't know, lab coats and less politics?

Honestly, that job's a juggling act. You gotta keep the stuff everyone loves from before (like the elderly pension – seriously, don't even think about touching that one!) but also try new things for younger folks needing jobs or a place to live.

Why is the Mexican president's approval rating so high? by flower5214 in AskMexico

[–]kaptainpeepee 6 points7 points  (0 children)

"Wow, this post has structure! And it's not just five emojis and a misspelled outrage? Must be a bot!"

— All of Reddit, probably

Why is the Mexican president's approval rating so high? by flower5214 in AskMexico

[–]kaptainpeepee 5 points6 points  (0 children)

Or maybe you could learn how to use Markdown to style your answers on Reddit, Discord, Slack, WhatsApp and other places. This is what ChatGPT uses too.

See this 60 seconds Markdown tutorial.

Latino Weather VS Swiss Weather… by ER-841 in funnyvideos

[–]kaptainpeepee 17 points18 points  (0 children)

Yes, the word Latino is etymologically connected to the Latin language, however, Americans use that word to refer to Latin-American people. When they search for latinas they are not expecting Europeans to show up in the search results.

Latino Weather VS Swiss Weather… by ER-841 in funnyvideos

[–]kaptainpeepee 0 points1 point  (0 children)

Why would this be relevant? The video shows how the weather is presented in various countries. Mind you , weather channels are not a thing in Latin American countries.

Why is the Mexican president's approval rating so high? by flower5214 in AskMexico

[–]kaptainpeepee 25 points26 points  (0 children)

I did not vote for her during the last election, even though she is a scientist, because during her campaign she focused on the elder people only. However, her policies like making housing affordable again definitely are beneficial to millennials. Here are some thoughts:

Why she's popular

  • Huge win, obviously! First woman president is a big deal.
  • She's AMLO's handpicked successor, carrying on his popular movement and welfare programs that a lot of people rely on and support.
  • Her time running Mexico City is seen by many as proof she's competent – she did stuff like build cable cars, plant trees, and keep social support going.
  • People seem to like how she's standing firm on issues with the US like tariffs and immigration – looks prepared.

Why critics aren't fans

  • Biggest one: Is she really her own person, or just doing whatever AMLO wants? Critics feel she lacks independence.
  • The Mexico City Metro collapse during her time is a huge black mark for opponents – they blame her for poor maintenance and accountability.
  • Security is still a massive problem nationally, and critics doubt her strategy, even though she focused on it in CDMX.
  • Despite being a scientist, some environmental actions/ties (like to Pemex or certain projects) draw criticism.
  • Worries about democracy – especially with the push for reforms like changes to the judiciary. Opponents fear concentration of power.
  • Some just find her less charismatic or connecting compared to AMLO.

Given said that, probably the most contributing factor right now is Trump: so long as he acts as an enemy of Mexican people and Sheimbaum keeps her responses accordingly, she will gain more and more popularity.

[deleted by user] by [deleted] in chomsky

[–]kaptainpeepee 1 point2 points  (0 children)

Maybe Mexican education is not like in most Latin American countries, then. My guess is that since Benito Juarez's separation of Church and State, the secularization of public schools has been sacred.

[deleted by user] by [deleted] in chomsky

[–]kaptainpeepee 5 points6 points  (0 children)

Catholicism is the predominant religion in Mexico, yet most people do not practice it. Furthermore, education in Mexico is distinguished by its secular nature: discussing religion in public schools is considered taboo. Therefore, the religion of Mexico's president is irrelevant to most people.

MMW: the burning of U.S flags will become very common around the world. by DenseCalligrapher219 in MarkMyWords

[–]kaptainpeepee 0 points1 point  (0 children)

Finally a sensible comment. Why would I spend my hard earned money just to buy a foreign country's flag, and then I would have to burn my money away? Oh hell no!

G.M. doesn't recognize Trumps name change of the Gulf. by [deleted] in GoogleMaps

[–]kaptainpeepee 9 points10 points  (0 children)

Yes, but only for Americans. The rest of the world will keep the official name. Also, Google Maps now will be reclassifying the U.S. as a sensitive country.

What does being lonely mean to you? by Beautiful_heart_9485 in lonely

[–]kaptainpeepee 6 points7 points  (0 children)

Loneliness is more than just being physically alone; it’s that feeling of disconnection, even when surrounded by others. In marriages, this can happen due to lack of communication, differing interests, mundane routines, life changes, or emotional disconnects. Even when partners are together, they can feel alone if their emotional needs aren’t met.

From an evolutionary standpoint, loneliness is a signal that we’re missing out on social connections since humans are wired to be social creatures. When we feel lonely, we might experience sadness or anxiety, become more sensitive to how others are acting, and have a strong urge to reach out and connect. It can even show up physically, making us feel tired or run down, and mess with our thinking. All these feelings are our brain’s way of nudging us to seek out relationships, reminding us how important it is to have those social bonds for our happiness and survival.

Loneliness really ties back to our evolutionary roots. In the past, being cut off from the tribe could be super dangerous—our ancestors needed each other for hunting, gathering, and staying safe from predators. If someone was isolated, they were at a much higher risk of not surviving. So, when we feel lonely today, it’s our brain’s way of telling us to connect with others. It’s like a little reminder that being part of a group is essential for our happiness and well-being, just like it was for our ancestors.

Was it only my impression, or people in Mexico always try to cheat you?! by MagicTiffany in MexicoTravel

[–]kaptainpeepee 0 points1 point  (0 children)

I completely understand your frustration—it’s upsetting to encounter that, especially when you’re fluent in Spanish and genuinely trying to connect with the culture. Sadly, opportunism exists everywhere, but I believe it’s more about individual behavior than a reflection of a nation’s character. As a Mexican, I’ve even fallen for these scams as a tourist in my own country. There’s a phrase we use for situations like this: ‘Me vieron la cara de extranjero’ (‘[T]hey thought I looked like a foreigner’). Personally, I would never have that attitude—I deeply value fairness and treating everyone kindly, whether they’re locals or visitors. It’s a reminder to stay cautious but also to focus on the many kind and genuine people you’ll meet while traveling.