Skip to content

Commit 4c049f7

Browse files
authored
Merge pull request #850 from CenterForOpenScience/feature/share-cleanupgrade-2025
[project][ENG-7225][ENG-8319] share clean(up)grade 2025 (milestone 2: upgrade)
2 parents a8b830a + c376d22 commit 4c049f7

File tree

94 files changed

+3080
-1644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3080
-1644
lines changed

.docker-compose.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CELERY_BROKER_URL=amqp://guest:guest@rabbitmq:5672
22
DATABASE_HOST=postgres
33
ELASTICSEARCH8_URL=https://elastic8:9200/
4-
# ELASTICSEARCH5_URL=http://elasticsearch:9200/
54
LOGIN_REDIRECT_URL=http://localhost:8003/
65
OSF_API_URL=http://localhost:8000
76
RABBITMQ_HOST=rabbitmq

.dockerignore

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,8 @@
11
**/.git/
22
**/*.pyc
3-
README.md
43
Dockerfile
54
docker-compose.yml
65
.dockerignore
76
.gitignore
87
celerybeat.pid
9-
/static/
10-
11-
/au.*/
12-
/be.*/
13-
/br.*/
14-
/ca.*/
15-
/ch.*/
16-
/com.*/
17-
/edu.*/
18-
/et.*/
19-
/eu.*/
20-
/gov.*/
21-
/info.*/
22-
/io.*/
23-
/org.*/
24-
/pt.*/
25-
/ru.*/
26-
/tr.*/
27-
/uk.*/
28-
/za.*/
8+
.venv/

.github/workflows/run_tests.yml

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,35 @@ permissions:
99
checks: write # for coveralls
1010

1111
jobs:
12+
lint_and_type:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Install poetry
18+
run: pipx install poetry
19+
20+
- name: setup python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.13'
24+
cache: 'poetry'
25+
26+
- name: install despondencies
27+
run: poetry install --with dev
28+
29+
- name: flake it
30+
run: poetry run flake8 .
31+
32+
- name: type-check
33+
run: poetry run mypy trove
34+
1235
run_tests:
1336
strategy:
1437
fail-fast: false
1538
matrix:
16-
python-version: ['3.10'] # TODO: 3.11, 3.12
17-
postgres-version: ['15', '17']
39+
python-version: ['3.13']
40+
postgres-version: ['17']
1841
runs-on: ubuntu-latest
1942
services:
2043
postgres:
@@ -30,19 +53,13 @@ jobs:
3053
ports:
3154
- 5432:5432
3255
elasticsearch8:
33-
image: elasticsearch:8.7.0
56+
image: elasticsearch:8.18.1
3457
env:
3558
xpack.security.enabled: false
3659
node.name: singlenode
3760
cluster.initial_master_nodes: singlenode
3861
ports:
3962
- 9208:9200
40-
elasticsearch5:
41-
image: elasticsearch:5.4
42-
env:
43-
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
44-
ports:
45-
- 9205:9200
4663
rabbitmq:
4764
image: rabbitmq:management
4865
ports:
@@ -54,32 +71,25 @@ jobs:
5471
- name: install non-py dependencies
5572
run: sudo apt-get update && sudo apt-get install -y libxml2-dev libxslt1-dev libpq-dev git gcc
5673

57-
- name: set up python${{ matrix.python-version }}
74+
- name: Install poetry
75+
run: pipx install poetry
76+
77+
- name: setup python
5878
uses: actions/setup-python@v5
5979
with:
6080
python-version: ${{ matrix.python-version }}
61-
cache: pip
62-
cache-dependency-path: |
63-
requirements.txt
64-
dev-requirements.txt
65-
66-
- name: install py dependencies
67-
run: pip install -r dev-requirements.txt
81+
cache: 'poetry'
6882

69-
- name: install share
70-
run: python setup.py develop
71-
72-
- name: flake it
73-
run: flake8 .
83+
- name: install despondencies
84+
run: poetry install --with dev
7485

7586
- name: run tests
7687
run: |
77-
coverage run -m pytest --create-db -x
78-
coverage xml -o _shtrove_coverage.xml
88+
poetry run coverage run -m pytest --create-db -x
89+
poetry run coverage xml -o _shtrove_coverage.xml
7990
env:
8091
DATABASE_PASSWORD: postgres
8192
ELASTICSEARCH8_URL: http://localhost:9208/
82-
# ELASTICSEARCH5_URL: http://localhost:9205/
8393

8494
- name: coveralls
8595
uses: coverallsapp/github-action@v2

Dockerfile

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.10-slim-bullseye as app
1+
FROM python:3.13-slim-bullseye AS app
22

33
RUN apt-get update \
44
&& apt-get install -y \
@@ -22,38 +22,58 @@ RUN apt-get update \
2222

2323
RUN update-ca-certificates
2424

25+
# set working directory once, use relative paths from "./"
2526
RUN mkdir -p /code
2627
WORKDIR /code
2728

28-
RUN pip install -U pip
29-
RUN pip install uwsgi==2.0.21
29+
###
30+
# python dependencies
3031

31-
COPY ./requirements.txt /code/requirements.txt
32-
COPY ./constraints.txt /code/constraints.txt
32+
# note: installs dependencies on the system, roundabouts `/usr/local/lib/python3.13/site-packages/`
3333

34-
RUN pip install --no-cache-dir -c /code/constraints.txt -r /code/requirements.txt
34+
ENV POETRY_NO_INTERACTION=1 \
35+
POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY=1 \
36+
POETRY_VIRTUALENVS_CREATE=0 \
37+
POETRY_VIRTUALENVS_IN_PROJECT=0 \
38+
POETRY_CACHE_DIR=/tmp/poetry-cache \
39+
POETRY_HOME=/tmp/poetry-venv
3540

36-
RUN apt-get remove -y \
37-
gcc \
38-
zlib1g-dev
41+
RUN python -m venv $POETRY_HOME
42+
43+
RUN $POETRY_HOME/bin/pip install poetry==2.1.3
44+
45+
COPY pyproject.toml poetry.lock ./
46+
47+
RUN $POETRY_HOME/bin/poetry install --compile --no-root
48+
49+
COPY ./ ./
3950

40-
COPY ./ /code/
51+
RUN $POETRY_HOME/bin/poetry install --compile --only-root
4152

4253
RUN python manage.py collectstatic --noinput
4354

4455
ARG GIT_TAG=
4556
ARG GIT_COMMIT=
46-
ENV VERSION ${GIT_TAG}
47-
ENV GIT_COMMIT ${GIT_COMMIT}
48-
49-
RUN python setup.py develop
57+
ENV VERSION=${GIT_TAG}
58+
ENV GIT_COMMIT=${GIT_COMMIT}
5059

5160
CMD ["python", "manage.py", "--help"]
5261

62+
### Dev
63+
FROM app AS dev
64+
65+
RUN $POETRY_HOME/bin/poetry install --compile --only dev
66+
5367
### Dist
5468
FROM app AS dist
5569

56-
### Dev
57-
FROM app AS dev
70+
RUN $POETRY_HOME/bin/poetry install --compile --only deploy
5871

59-
RUN pip install --no-cache-dir -c /code/constraints.txt -r /code/dev-requirements.txt
72+
# remove packages needed only for install
73+
RUN apt-get remove -y \
74+
gcc \
75+
zlib1g-dev \
76+
&& apt-get clean \
77+
&& apt-get autoremove -y \
78+
&& rm -rf /var/lib/apt/lists/* \
79+
&& rm -rf /tmp/poetry-*

dev-requirements.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

docker-compose.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
####################
3333

3434
elastic8_setup:
35-
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0
35+
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.3
3636
volumes:
3737
- elastic8_cert_vol:/usr/share/elasticsearch/config/certs
3838
user: "0"
@@ -89,7 +89,7 @@ services:
8989
depends_on:
9090
elastic8_setup:
9191
condition: service_healthy
92-
image: docker.elastic.co/elasticsearch/elasticsearch:8.7.0
92+
image: docker.elastic.co/elasticsearch/elasticsearch:8.18.3
9393
ports:
9494
- 9208:9200
9595
volumes:
@@ -126,21 +126,12 @@ services:
126126
- share_network
127127

128128
postgres:
129-
image: postgres:10
130-
command:
131-
- /bin/bash
132-
- -c
133-
- echo "$$POSTGRES_INITDB" > /docker-entrypoint-initdb.d/commands.sh &&
134-
chmod +x /docker-entrypoint-initdb.d/commands.sh &&
135-
/docker-entrypoint.sh postgres
129+
image: postgres:15.4
136130
ports:
137131
- 5433:5432
138132
environment:
139133
POSTGRES_DB: share
140134
POSTGRES_HOST_AUTH_METHOD: trust
141-
POSTGRES_INITDB: |
142-
sed -i -e 's/max_connections.*/max_connections = 5000/' /var/lib/postgresql/data/postgresql.conf
143-
sed -i -e 's/#log_min_duration_statement = .*/log_min_duration_statement = 0/' /var/lib/postgresql/data/postgresql.conf
144135
volumes:
145136
- "${POSTGRES_DATA_VOL:-postgres_data_vol}:/var/lib/postgresql/data/"
146137
stdin_open: true
@@ -152,27 +143,28 @@ services:
152143
##################
153144

154145
requirements:
155-
image: quay.io/centerforopenscience/share:develop
146+
build:
147+
context: .
148+
dockerfile: Dockerfile
149+
target: dev
156150
command:
157151
- /bin/bash
158152
- -c
159-
- apt-get update &&
160-
apt-get install -y gcc &&
161-
pip install -r requirements.txt -r dev-requirements.txt &&
162-
(python3 -m compileall /usr/local/lib/python3.10 || true) &&
163-
rm -Rf /python3.10/* &&
164-
apt-get remove -y gcc &&
165-
cp -Rf -p /usr/local/lib/python3.10 / &&
166-
python3 setup.py develop
153+
- $$POETRY_HOME/bin/poetry install --compile --with=dev &&
154+
rm -Rf /python3.13/* &&
155+
cp -Rf -p /usr/local/lib/python3.13 /
167156
restart: 'no'
168157
volumes:
169158
- ./:/code:cached
170-
- share_requirements_vol:/python3.10
159+
- share_requirements_vol:/python3.13
171160
networks:
172161
- share_network
173162

174163
worker:
175-
image: quay.io/centerforopenscience/share:develop
164+
build:
165+
context: .
166+
dockerfile: Dockerfile
167+
target: dev
176168
command:
177169
/bin/bash -c 'cp -r /elastic8_certs /elastic_certs && chown -R daemon:daemon /elastic_certs/ && /usr/local/bin/celery --app project worker --uid daemon -l INFO'
178170
depends_on:
@@ -183,7 +175,7 @@ services:
183175
- indexer
184176
volumes:
185177
- ./:/code:cached
186-
- share_requirements_vol:/usr/local/lib/python3.10
178+
- share_requirements_vol:/usr/local/lib/python3.13
187179
- elastic8_cert_vol:/elastic8_certs
188180
env_file:
189181
- .docker-compose.env
@@ -195,7 +187,10 @@ services:
195187
- share_network
196188

197189
web:
198-
image: quay.io/centerforopenscience/share:develop
190+
build:
191+
context: .
192+
dockerfile: Dockerfile
193+
target: dev
199194
command: python manage.py runserver 0.0.0.0:8000
200195
ports:
201196
- 8003:8000
@@ -205,7 +200,7 @@ services:
205200
- elastic8
206201
volumes:
207202
- ./:/code:cached
208-
- share_requirements_vol:/usr/local/lib/python3.10
203+
- share_requirements_vol:/usr/local/lib/python3.13
209204
- elastic8_cert_vol:/elastic8_certs
210205
env_file:
211206
- .docker-compose.env
@@ -217,15 +212,18 @@ services:
217212
- share_network
218213

219214
indexer:
220-
image: quay.io/centerforopenscience/share:develop
215+
build:
216+
context: .
217+
dockerfile: Dockerfile
218+
target: dev
221219
command: python manage.py shtrove_indexer_run
222220
depends_on:
223221
- postgres
224222
- rabbitmq
225223
- elastic8
226224
volumes:
227225
- ./:/code:cached
228-
- share_requirements_vol:/usr/local/lib/python3.10
226+
- share_requirements_vol:/usr/local/lib/python3.13
229227
- elastic8_cert_vol:/elastic8_certs
230228
env_file:
231229
- .docker-compose.env

0 commit comments

Comments
 (0)