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

Refactor: move the application directory up a level #42

Merged
merged 2 commits into from
Jun 11, 2024
Merged
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
38 changes: 21 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@
"dockerComposeFile": ["../compose.yml"],
"service": "dev",
"runServices": ["dev", "docs"],
"workspaceFolder": "/home/calitp/app",
"workspaceFolder": "/calitp/app",
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
]
}
}
12 changes: 6 additions & 6 deletions appcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ RUN useradd --create-home --shell /bin/bash $USER && \
touch /var/run/nginx.pid && \
chown -R $USER /var/run/nginx.pid && \
# setup directories and permissions for gunicorn, (eventual) app
mkdir -p /home/$USER/app && \
mkdir -p /home/$USER/run && \
chown -R $USER /home/$USER && \
mkdir -p /$USER/app && \
mkdir -p /$USER/run && \
chown -R $USER /$USER && \
# install server components
apt-get update && \
apt-get install -qq --no-install-recommends build-essential nginx gettext && \
python -m pip install --upgrade pip

# enter run (gunicorn) directory
WORKDIR /home/$USER/run
WORKDIR /$USER/run

# switch to non-root $USER
USER $USER
Expand All @@ -43,13 +43,13 @@ RUN pip install --no-cache-dir -r requirements.txt

# copy gunicorn config file
COPY appcontainer/gunicorn.conf.py gunicorn.conf.py
ENV GUNICORN_CONF "/home/$USER/run/gunicorn.conf.py"
ENV GUNICORN_CONF "/$USER/run/gunicorn.conf.py"

# overwrite default nginx.conf
COPY appcontainer/nginx.conf /etc/nginx/nginx.conf

# enter app directory
WORKDIR /home/$USER/app
WORKDIR /$USER/app

# basic bash entrypoint
ENTRYPOINT ["/bin/bash"]
2 changes: 1 addition & 1 deletion appcontainer/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import multiprocessing

# the unix socket defined in nginx.conf
bind = "unix:/home/calitp/run/gunicorn.sock"
bind = "unix:/calitp/run/gunicorn.sock"

# Recommend (2 x $num_cores) + 1 as the number of workers to start off with
workers = multiprocessing.cpu_count() * 2 + 1
Expand Down
4 changes: 2 additions & 2 deletions appcontainer/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ http {
upstream app_server {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response
server unix:/home/calitp/run/gunicorn.sock fail_timeout=0;
server unix:/calitp/run/gunicorn.sock fail_timeout=0;
}

server {
Expand All @@ -39,7 +39,7 @@ http {

# path for static files
location /static/ {
alias /home/calitp/app/static/;
alias /calitp/app/static/;
expires 1y;
add_header Cache-Control public;
}
Expand Down
6 changes: 3 additions & 3 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
ports:
- "8000"
volumes:
- .:/home/calitp/app
- .:/calitp/app

dev:
build:
Expand All @@ -21,7 +21,7 @@ services:
ports:
- "8000"
volumes:
- .:/home/calitp/app
- .:/calitp/app

docs:
image: docker-python-web:dev
Expand All @@ -30,4 +30,4 @@ services:
ports:
- "8001"
volumes:
- .:/home/calitp/app
- .:/calitp/app