-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from effective-altruism-australia/master
Make debuggin/dev improvements and add internal reports and redacted partner reports
- Loading branch information
Showing
10 changed files
with
276 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile | ||
{ | ||
"name": "ubuntu16.04", | ||
"build": { | ||
// 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" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [8000], | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
"postCreateCommand": "cat /etc/os-release", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
"extensions": [ | ||
"ms-python.python@2021.9.1246542782", | ||
"ms-python.debugpy@2023.1.12492010" | ||
] | ||
|
||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "devcontainer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile | ||
{ | ||
"name": "ubuntu24.04", | ||
"build": { | ||
// 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.ubuntu24.04" | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [8000], | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
"postCreateCommand": "cat /etc/os-release" | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "devcontainer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Django: Runserver", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"python": "${workspaceRoot}/donation_portal_env/bin/python", | ||
"program": "${workspaceRoot}/manage.py", | ||
"args": [ | ||
"runserver", | ||
"--no-color", | ||
"--noreload" | ||
], | ||
}, | ||
{ | ||
"name": "Django: Shell", | ||
"type": "python", | ||
"request": "launch", | ||
"stopOnEntry": false, | ||
"python": "${workspaceRoot}/donation_portal_env/bin/python", | ||
"program": "${workspaceRoot}/manage.py", | ||
"args": [ | ||
"shell" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "/workspaces/donation_portal-2/donation_portal_env/bin/python2.7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# For local development and testing only. | ||
|
||
FROM ubuntu:24.04 | ||
|
||
# Avoid prompts from apt | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Set environment variables | ||
ENV PYENV_ROOT=/root/.pyenv | ||
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH | ||
|
||
# Update and install dependencies | ||
RUN apt-get update && apt-get upgrade -y \ | ||
&& apt-get install -y \ | ||
# Essential build tools | ||
build-essential \ | ||
# Libraries for building Python | ||
libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev \ | ||
# Additional libraries that some Python packages might need | ||
libncursesw5-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \ | ||
# Useful tools | ||
wget curl git vim sudo \ | ||
# App specific dependencies | ||
wkhtmltopdf \ | ||
xauth \ | ||
xvfb \ | ||
# PostgreSQL | ||
postgresql \ | ||
libpq-dev \ | ||
# Redis | ||
redis-server \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a new user "devuser" with user ID 1000 | ||
RUN useradd -m -s /bin/bash -u 1000 devuser | ||
|
||
# Add the user to the sudo group | ||
RUN usermod -aG sudo devuser | ||
|
||
# Set up password-less sudo for the user | ||
RUN echo "devuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
|
||
# Switch to the new user | ||
USER devuser | ||
|
||
# Install pyenv | ||
RUN curl https://pyenv.run | bash | ||
|
||
# Add pyenv initialization to bash profile | ||
RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc | ||
|
||
# Install Python versions | ||
RUN pyenv install 2.7.18 | ||
|
||
# Set global Python version | ||
RUN pyenv global 2.7.18 | ||
|
||
# Start PostgreSQL, set a password and create eaa database | ||
USER postgres | ||
RUN service postgresql start && \ | ||
psql -c "ALTER USER postgres PASSWORD 'password';" && \ | ||
psql -c "CREATE DATABASE eaa;" | ||
USER devuser | ||
|
||
# Upgrade pip to the last version that supports Python 2.7 and install the last | ||
# version of virtualenv that works for Python 2.7 | ||
RUN pip install --upgrade "pip<21.0" && \ | ||
pip install virtualenv==16.7.10 | ||
|
||
# Install nvm and node | ||
ENV NVM_DIR=/root/.nvm | ||
RUN mkdir $NVM_DIR && \ | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash && \ | ||
. $NVM_DIR/nvm.sh && nvm install 8.14.0 | ||
|
||
# Copy over python dependencies | ||
# COPY deps deps | ||
|
||
# Create and activate a Python virtual environment and install the dependencies | ||
# RUN virtualenv donation_portal_env && \ | ||
# . donation_portal_env/bin/activate && \ | ||
# pip install -r deps/pip.base && \ | ||
# pip install -r deps/pip | ||
|
||
# Document that the service listens on port 8000. Note, this doesn't actually | ||
# open the port - you'll need to run `docker run -p 8000:8000 <image name>`. | ||
EXPOSE 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Run stripe webhook listener | ||
echo "Remember to locally run: stripe listen --forward-to localhost:8000/stripe-webhooks/" | ||
|
||
# Start PostgreSQL service | ||
sudo service postgresql start | ||
|
||
# Start Redis service | ||
sudo service redis-server start | ||
|
||
# Start celery | ||
celery -A donation_portal worker -l info & | ||
|
||
# Apply database migrations | ||
python manage.py migrate | ||
|
||
# Run the Django development server | ||
python manage.py runserver 0.0.0.0:8000 |