diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..740def5 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +# For more information, please refer to https://aka.ms/vscode-docker-python +FROM python:3.8-slim-buster + +EXPOSE 5000 + +# Keeps Python from generating .pyc files in the container +ENV PYTHONDONTWRITEBYTECODE=1 + +# Turns off buffering for easier container logging +ENV PYTHONUNBUFFERED=1 + +# Set the working directory for any subsequent commands to the app directory +WORKDIR /app + +# Expose a voume for the app directory +VOLUME /app + +# Creates a non-root user with an explicit UID and adds permission to access the /app folder +# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers +RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app +USER appuser + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f8a19ba..6fd0551 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,16 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.177.0/containers/docker-existing-dockerfile { - "name": "Existing Dockerfile", + "name": "simpleblogapi-dev-container", + "dockerComposeFile": "./docker-compose.yml", + "service": "simpleblogapi", + "workspaceFolder": "/app", // Sets the run context to one level up instead of the .devcontainer folder. - "context": "..", + // "context": "..", // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. - "dockerFile": "../Dockerfile", + // "dockerFile": "../Dockerfile", // Set *default* container specific settings.json values on container create. "settings": { @@ -15,10 +18,10 @@ }, // Add the IDs of extensions you want installed when the container is created. - "extensions": [] + "extensions": [], // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], + "forwardPorts": [5000] // Uncomment the next line to run commands after the container is created - for example installing curl. // "postCreateCommand": "apt-get update && apt-get install -y curl", diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..5d408d2 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.4' + +services: + simpleblogapi: + image: simpleblogapi + build: . + volumes: + - ../:/app + ports: + - 5000:5000 + tty: true diff --git a/docker-compose.yml b/docker-compose.yml index 84f6345..eaf6f70 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,3 +8,4 @@ services: dockerfile: ./Dockerfile ports: - 5000:5000 + tty: true