Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dev container config #22978

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "Addons-Server Devcontainer",
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
"workspaceFolder": "/workspaces/addons-server",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/addons-server,type=bind",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker": {
"version": "latest",
"enableNonRootDocker": "true",
"moby": "true"
}
},
"forwardPorts": [80],
"appPort": [80],
"portsAttributes": {
"80": {
"label": "Addons-Server",
"onAutoForward": "notify",
"protocol": "http",
"requireLocalPort": true,
"elevateIfNeeded": true
}
},
"postStartCommand": "make up"
}
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
- package-ecosystem: "npm"
directory: "/"
schedule:
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.css.tmp
.devcontainer/*
*.egg-info
*.js.tmp
*.less.css
Expand Down Expand Up @@ -53,7 +54,10 @@ tmp/*
# End of .gitignore. Please keep this in sync with the top section of .dockerignore

# do not ignore the following files
!.devcontainer/devcontainer.json
!.devcontainer/docker-compose.yml
!.devcontainer/Dockerfile
!deps/.gitkeep
!docker-compose.private.yml
!private/README.md
!storage/.gitignore
!deps/.gitkeep
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ x-env-mapping: &env
- MEMCACHE_LOCATION=memcached:11211
- MYSQL_DATABASE=olympia
- MYSQL_ROOT_PASSWORD=docker
- OLYMPIA_SITE_URL=http://olympia.test
- PYTHONDONTWRITEBYTECODE=1
- PYTHONUNBUFFERED=1
- PYTHONBREAKPOINT=ipdb.set_trace
Expand All @@ -21,6 +20,7 @@ x-env-mapping: &env
- HISTCONTROL=erasedups
- CIRCLECI
- DATA_BACKUP_SKIP
- OLYMPIA_SITE_URL

x-olympia: &olympia
<<: *env
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def get_olympia_mount(docker_target):

return olympia_mount, olympia_mount_source

def get_olympia_site_url():
# In codespaces, we set the site URL to the codespace name port 80
# this will map to the nginx service in the devcontainer.
if os.environ.get('CODESPACE_NAME'):
return f'https://{os.environ.get("CODESPACE_NAME")}-80.githubpreview.dev'
# On local hosts, we set the site URL to olympia.test
return 'http://olympia.test'


# Env file should contain values that are referenced in docker-compose*.yml files
# so running docker compose commands produce consistent results in terminal and make.
Expand Down Expand Up @@ -123,6 +131,7 @@ def main():
# use a value derived from other stable values.
debug = os.environ.get('DEBUG', str(False if is_production else True))
olympia_deps = os.environ.get('OLYMPIA_DEPS', docker_target)
olympia_site_url = get_olympia_site_url()

set_env_file(
{
Expand All @@ -140,6 +149,7 @@ def main():
'HOST_MOUNT_SOURCE': olympia_mount_source,
'DEBUG': debug,
'OLYMPIA_DEPS': olympia_deps,
'OLYMPIA_SITE_URL': olympia_site_url,
}
)

Expand Down
Loading