-
Notifications
You must be signed in to change notification settings - Fork 3
start server via docker #373
Changes from 6 commits
abb59a2
1eb60cf
1166161
fd7be07
6839fa2
61c665e
77e6460
96a4229
9e31d4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ | |
.cache | ||
__pycache__ | ||
*.pyc | ||
|
||
/app-dev.cfg |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ ARG install_dev | |
COPY requirements.dev.txt ./ | ||
RUN if [ "${install_dev}" = "y" ]; then pip install -r requirements.dev.txt; fi | ||
|
||
COPY --from=client --chown=elife:elife /home/node/client/ ${PROJECT_FOLDER}/client/ | ||
COPY --from=client --chown=elife:elife /home/node/client/dist/ ${PROJECT_FOLDER}/client/dist/ | ||
COPY --chown=elife:elife peerscout/ ${PROJECT_FOLDER}/peerscout/ | ||
COPY --chown=elife:elife server.sh ${PROJECT_FOLDER}/ | ||
COPY --chown=elife:elife update-data-and-reload.sh ${PROJECT_FOLDER}/ | ||
|
@@ -35,7 +35,7 @@ COPY --chown=elife:elife app-defaults.cfg ${PROJECT_FOLDER}/ | |
|
||
USER root | ||
RUN mkdir .data && chown www-data:www-data .data | ||
RUN mkdir logs && chown www-data:www-data logs | ||
RUN mkdir logs && chown www-data:www-data logs && chmod -R a+w logs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The image is (or would be) used to run the server as well as the "ETL" scripts (migrate schema, load data etc.). The latter is currently meant to be run via the |
||
|
||
USER www-data | ||
CMD ["venv/bin/python"] | ||
CMD ["/srv/peerscout/server.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: '3' | ||
|
||
services: | ||
init: | ||
build: | ||
context: ./docker/init | ||
dockerfile: Dockerfile | ||
image: elifesciences/peerscout_init:${IMAGE_TAG} | ||
volumes: | ||
- config-aws:/home/elife/volume-config-aws | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some weird copying from one folder to the other to avoid ownership clashes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem with that, but why needing a volume if the copying is executed every time the container starts anyway? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find that when the container is not run as root or the developer's user, then just mounting the credentials won't work because the permissions are meant to set up that only the user can read them. This makes the developers credentials available via the volume. (The init container is run as root, and therefore has permissions) One alternative would maybe be to run the container using the developer's user (which seem to also be more complicated than it should). I experimented with a few approaches across the projects. Not sure which one is best. Any suggestions? |
||
- ~/.aws:/home/elife/user-config-aws | ||
|
||
db: | ||
image: postgres:9.6 | ||
restart: always | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_DB: peerscout_db | ||
POSTGRES_USER: peerscout_user | ||
POSTGRES_PASSWORD: peerscout_password | ||
healthcheck: | ||
test: ["CMD", "bash", "-c", "echo > /dev/tcp/localhost/5432"] | ||
interval: 10s | ||
timeout: 10s | ||
retries: 5 | ||
ports: | ||
- "9432:5432" | ||
|
||
peerscout: | ||
depends_on: | ||
- client | ||
- db | ||
- init | ||
volumes: | ||
- ./app-dev.cfg:/srv/peerscout/app.cfg | ||
- ./.data:/srv/peerscout/.data | ||
- config-aws:/home/elife/.aws | ||
|
||
volumes: | ||
config-aws: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM busybox:1.30.1 | ||
|
||
COPY init.sh /bin/ | ||
|
||
CMD /bin/init.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# elife user id | ||
USER_ID=1000 | ||
echo 'changing ownership to $USER_ID, and...' | ||
|
||
echo 'copying aws credentials...' | ||
|
||
cp -r /home/elife/user-config-aws/* /home/elife/volume-config-aws | ||
chown -R $USER_ID:$USER_ID /home/elife/volume-config-aws | ||
|
||
echo 'done' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need
dist
when running the server (no need to copynode_modules
& co)