Skip to content

Commit

Permalink
refactor(container): move app root out of /home
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Jun 10, 2024
1 parent 3b06b2c commit 5f949ca
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
36 changes: 18 additions & 18 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +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.
"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"
]
"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"
]
}
}
}
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

0 comments on commit 5f949ca

Please sign in to comment.