Skip to content

Commit

Permalink
Updated devcontainer to use production container (#4039)
Browse files Browse the repository at this point in the history
Co-authored-by: Conor Brady <[email protected]>

Updates devcontainer to use the same docker image that's run in the cluster
  • Loading branch information
compscidr authored Oct 23, 2024
1 parent d3136ca commit 80235d1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 102 deletions.
52 changes: 41 additions & 11 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,45 @@
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile.vscode",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// 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",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"dockerFile": "../Dockerfile",
// make sure you don't have any local .venv in wps/api or it won't work
// note: we don't use a workspace mount because then you'll only see the files in /api, when
// you probably want to see everything. This means you must cd from /workspace to /app in order
// to actually run things though. the following mount will at least make the /app folder in the
// docker container change when files in api change.
"mounts": [
"source=${localWorkspaceFolder}/api,target=/app,type=bind"
],
"remoteUser": "worker",
"containerUser": "worker",
"updateRemoteUserUID": false, // without this you wind up as ubuntu user
// this lets the container access the database container. On linux I had to configure the db
// host to localhost for it to work in the .env file in api/app
// tested with the database running from the docker-compose file with `docker compose up db`
"forwardPorts": [
8080
],
"runArgs": [
"--network=host",
"--platform",
"linux/amd64",
"--hostname=wps-dev",
],
// sets us in the correct location, and install dev requirements like pytest
"postCreateCommand": "echo 'cd /app' >> ~/.bashrc && cd /app && poetry install",
// by default the dockerfile sets the shell to /bin/sh - you can use whatever you like here
// but if you use bash, it will automatically set you in the /app folder rather than workspace
// when the terminal connects
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG DOCKER_IMAGE=image-registry.openshift-image-registry.svc:5000/e1e498-tools/wps-api-base:02-10-2024
ARG DOCKER_IMAGE=ghcr.io/bcgov/wps/wps-api-base:10-21-2024
# To build locally, point to a local base image you've already built (see openshift/wps-api-base)
# e.g. : docker build --build-arg DOCKER_IMAGE=wps-api-base:my-tag .

Expand Down Expand Up @@ -70,8 +70,8 @@ COPY ./api/alembic.ini /app
COPY ./api/prestart.sh /app
COPY ./api/start.sh /app

# Copy installed Python packages
COPY --from=builder /home/worker/.cache/pypoetry/virtualenvs /home/worker/.cache/pypoetry/virtualenvs
# Copy installed Python packages (the chown lets us install the dev packages later without root if we want)
COPY --from=builder --chown=$USERNAME:$USER_GID /home/worker/.cache/pypoetry/virtualenvs /home/worker/.cache/pypoetry/virtualenvs

# The fastapi docker image defaults to port 80, but openshift doesn't allow non-root users port 80.
EXPOSE 8080
Expand Down
88 changes: 0 additions & 88 deletions Dockerfile.vscode

This file was deleted.

0 comments on commit 80235d1

Please sign in to comment.