File tree Expand file tree Collapse file tree 7 files changed +130
-33
lines changed
Expand file tree Collapse file tree 7 files changed +130
-33
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ FLASK_APP=webapp.app
66FLASK_READ_ONLY_MODE = false
77
88# Database
9- FLASK_DATABASE_URL = postgresql://assets:password@localhost :5432/assets
9+ FLASK_DATABASE_URL = postgresql://assets:password@postgres :5432/assets
1010
1111# Swift server
12- FLASK_OS_AUTH_URL = http://localhost :8080/auth/v1.0
12+ FLASK_OS_AUTH_URL = http://swift :8080/auth/v1.0
1313FLASK_OS_USERNAME = test:tester
1414FLASK_OS_PASSWORD = testing
1515FLASK_OS_AUTH_VERSION = 1.0
Original file line number Diff line number Diff line change @@ -4,31 +4,21 @@ on: pull_request
44jobs :
55 run-image :
66 runs-on : ubuntu-latest
7-
8- services :
9- postgres :
10- image : postgres
11- env :
12- POSTGRES_DB : assets
13- POSTGRES_USER : assets
14- POSTGRES_PASSWORD : password
15- ports :
16- - 5432:5432
17- swift :
18- image : bouncestorage/swift-aio
19- ports :
20- - 8080:8080
217 steps :
228 - uses : actions/checkout@v3
239
24- - name : Build image
25- run : DOCKER_BUILDKIT=1 docker build --tag assets-ubuntu-com .
10+ - name : Install Taskfile
11+ uses : arduino/setup-task@v2
12+ with :
13+ version : 3.x
14+ repo-token : ${{ secrets.GITHUB_TOKEN }}
15+
16+ - name : Run project
17+ run : task && sleep 60
2618
27- - name : Run image
19+ - name : Ping application and verify it's running
2820 run : |
29- docker run --detach --env-file .env --network host assets-ubuntu-com
30- sleep 1
31- curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost
21+ curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost:8017
3222
3323 run-tests :
3424 runs-on : ubuntu-latest
5343 sudo pip3 install dotrun requests==2.31.0 # requests version is pinned to avoid breaking changes, can be removed once issue is resolved: https://github.com/docker/docker-py/issues/3256
5444 chmod -R 777 .
5545 echo "FLASK_DISABLE_AUTH_FOR_TESTS=true" >> .env
46+ echo "FLASK_DATABASE_URL=postgresql://assets:password@localhost:5432/assets" >> .env
47+ echo "FLASK_OS_AUTH_URL=http://localhost:8080/auth/v1.0" >> .env
5648
5749 - name : Install dependencies
5850 run : dotrun install
@@ -121,7 +113,7 @@ jobs:
121113 - name : Install python dependencies
122114 run : |
123115 python3 -m pip install --upgrade pip
124- sudo pip3 install flake8 black
116+ sudo pip3 install flake8 black==25.1.0
125117
126118 - name : Lint python
127119 run : yarn lint-python
Original file line number Diff line number Diff line change @@ -43,13 +43,23 @@ RUN yarn build
4343# ===
4444FROM python-dependencies AS production
4545
46+ # Install Node.js and yarn for running lint and format commands
47+ RUN apt-get update && apt-get install --no-install-recommends --yes \
48+ curl gnupg \
49+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
50+ && apt-get install --no-install-recommends --yes nodejs \
51+ && npm install -g yarn \
52+ && apt-get clean && rm -rf /var/lib/apt/lists/*
53+
4654# Set up environment
4755WORKDIR /srv
56+ ENV PATH="/srv/.venv/bin:$PATH"
4857
4958# Import code, build assets and mirror list
50- RUN rm -rf package.json yarn.lock requirements.txt
59+ RUN rm -rf requirements.txt
5160COPY --from=build /srv/static/css static/css
5261COPY --from=build /srv/static/js/dist static/js/dist
62+ COPY --from=yarn-dependencies /srv/node_modules node_modules
5363
5464# Set revision ID
5565ARG BUILD_ID
Original file line number Diff line number Diff line change @@ -9,26 +9,30 @@ We use [Yarn](https://yarnpkg.com/lang/en/) for building static files like CSS t
991 . To run the project simply, you will need to install ` dotrun ` , by following the [ installation instructions] ( https://github.com/canonical/dotrun#installation )
10102 . docker: Docker is used to run the project. You can install it by following the [ installation instructions] ( https://docs.docker.com/install/ )
11113 . docker-compose: Docker compose is used to run the Postgres database and the SWIFT server (files server), you can install it by following the [ installation instructions] ( https://docs.docker.com/compose/install/ )
12+ 4 . [ Taskfile] ( https://taskfile.dev/docs/installation ) : It is used to run everything with a single ` task ` command.
1213
1314## Running the project
1415
15- ### Starting the database and the SWIFT server
16+ Please make sure you are running the latest version of
17+ - [ Docker] ( https://docs.docker.com/engine/install/ )
18+ - [ Docker compose] ( https://docs.docker.com/compose/install/ )
19+ - [ Taskfile] ( https://taskfile.dev/docs/installation )
1620
17- To start the database and the SWIFT server, run:
21+ Starting the project with all it's services is as simple as
1822
1923``` bash
20- docker-compose up -d
24+ task
2125```
2226
23- ### Starting the project
27+ That's it! The project should now be running at http://localhost:8017/manager .
2428
25- To start the project, run:
29+ You can stop the project using
2630
2731``` bash
28- dotrun
29- ```
32+ task stop
33+ ````
3034
31- That's it! The project should now be running at http://localhost:8017/manager .
35+ Please checkout [Taskfile.yml](/Taskfile.yml) for all available commands
3236
3337# ## Generating API tokens
3438
Original file line number Diff line number Diff line change 1+ version : " 3"
2+
3+ dotenv : [".env", ".env.local"]
4+
5+ tasks :
6+ default :
7+ desc : " Start the project"
8+ cmds :
9+ - docker compose up -d
10+
11+ stop :
12+ desc : " Stop the project"
13+ cmds :
14+ - docker compose down
15+
16+ cleanup :
17+ desc : " Stop containers and remove volumes"
18+ cmds :
19+ - docker compose down -v
20+
21+ rebuild :
22+ desc : " Rebuild the project. Only run this if you have made changes to the Docker related files (Dockerfile, docker-compose.yaml)."
23+ cmds :
24+ - docker compose up -d --build
25+
26+ format-python :
27+ desc : " Format python code"
28+ cmds :
29+ - docker exec assetsubuntucom-app-1 yarn format-python
30+
31+ lint :
32+ desc : " Run code linters"
33+ cmds :
34+ - docker exec assetsubuntucom-app-1 yarn lint
35+
36+ test-python :
37+ desc : " Run tests"
38+ cmds :
39+ - docker exec assetsubuntucom-app-1 yarn test-python
40+
41+ test-e2e :
42+ desc : " Run end-to-end tests"
43+ cmds :
44+ - docker exec assetsubuntucom-app-1 yarn playwright install
45+ - docker exec assetsubuntucom-app-1 yarn test-e2e
46+
47+ build :
48+ desc : " Build the project"
49+ cmds :
50+ - docker exec assetsubuntucom-app-1 yarn build
51+
52+ watch :
53+ desc : " Watch the project"
54+ cmds :
55+ - docker exec assetsubuntucom-app-1 yarn watch
56+
57+ test :
58+ desc : " Run all tests"
59+ cmds :
60+ - task : lint
61+ - task : test-python
Original file line number Diff line number Diff line change @@ -9,12 +9,39 @@ services:
99 - postgres-data:/var/lib/postgresql/data
1010 ports :
1111 - " 5432:5432"
12+ healthcheck :
13+ test : ["CMD-SHELL", "pg_isready -U assets -d assets"]
14+ interval : 5s
15+ timeout : 5s
16+ retries : 5
1217 swift :
1318 image : openstackswift/saio:latest
1419 ports :
1520 - " 8080:8080"
1621 volumes :
1722 - swift-data:/srv
23+ app :
24+ build : .
25+ env_file :
26+ - path : .env
27+ - path : .env.local
28+ required : false
29+ ports :
30+ - " ${PORT}:80"
31+ volumes :
32+ - .:/srv
33+ - /srv/.venv
34+ depends_on :
35+ postgres :
36+ condition : service_healthy
37+ swift :
38+ condition : service_started
39+ healthcheck :
40+ test : ["CMD", "curl", "-f", "http://localhost:80/manager"]
41+ interval : 5s
42+ timeout : 5s
43+ retries : 30
44+ start_period : 30s
1845volumes :
1946 postgres-data :
2047 swift-data :
Original file line number Diff line number Diff line change @@ -19,4 +19,7 @@ pydantic-settings==2.10.1
1919python-slugify == 8.0.4
2020trino == 0.335.0
2121google-auth == 2.40.3
22- cryptography == 46.0.1
22+ cryptography == 46.0.1
23+ setuptools == 79.0.1
24+ black == 25.1.0
25+ flake8 == 7.1.1
You can’t perform that action at this time.
0 commit comments