-
Notifications
You must be signed in to change notification settings - Fork 141
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
feat: file upload (minio, s3, frontend...) #443
base: master
Are you sure you want to change the base?
Changes from 25 commits
3b3bcb4
36f89f2
7b44b85
1daf3c9
592dacb
ac22b8b
b8ebc5d
1244dc1
95dffdb
7080193
a5f6e73
bff986f
0673b4f
ffe42ef
ed6728b
0d0b373
08e8337
833eab9
983cde7
4e99980
599c689
74a947b
8f69e89
dbac239
36922cb
9885347
602d924
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,9 +1,68 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
postgres: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image: postgres:16.1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
env_file: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- .env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- '${DOCKER_DATABASE_PORT:-5432}:5432' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POSTGRES_DB: $DOCKER_DATABASE_NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POSTGRES_USER: $DOCKER_DATABASE_USERNAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
POSTGRES_PASSWORD: $DOCKER_DATABASE_PASSWORD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
healthcheck: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_NAME'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
interval: 10s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout: 5s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retries: 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
initializedatabase: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
build: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context: . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dockerfile: docker/initialize-database.dockerfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
depends_on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
postgres: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
condition: service_healthy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DATABASE_URL: 'postgres://${DOCKER_DATABASE_USERNAME}:${DOCKER_DATABASE_PASSWORD}@postgres:${DOCKER_DATABASE_PORT}/${DOCKER_DATABASE_NAME}' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
minio: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image: 'minio/minio:RELEASE.2024-07-16T23-46-41Z-cpuv1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- '${DOCKER_FORWARD_MINIO_PORT:-9000}:9000' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- '${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}:9090' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MINIO_ROOT_USER: $DOCKER_MINIO_USERNAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MINIO_ROOT_PASSWORD: $DOCKER_MINIO_PASSWORD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
volumes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- 'minio:/data/minio' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
healthcheck: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
test: ['CMD', 'mc', 'ready', 'local'] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
interval: 5s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout: 5s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retries: 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+28
to
+44
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. 🛠️ Refactor suggestion MinIO Service Configuration & Environment Variable Consistency - command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}"
+ command: minio server /data/minio --console-address ":${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
createbuckets: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
image: minio/mc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
depends_on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
minio: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
condition: service_healthy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Set an alias, meaning myminio is an alias for the host, the username and the password, avoiding to type it again in the next commands | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# As an admin, add a new user to scope minio access to this new user, avoiding to use the admin credentials in the application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Set the policy readwrite to the user we previously created on the previously created alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Create the bucket on the previously created alias | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Set the public access policy to download, meaning readonly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
entrypoint: > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/bin/sh -c " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/usr/bin/mc mb myminio/$S3_BUCKET_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
exit 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+56
to
+63
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. 🛠️ Refactor suggestion Add validation and error handling to createbuckets service. The current shell script doesn't check for errors or validate that operations have succeeded, which could lead to silent failures. Add error checking to ensure each command completes successfully: entrypoint: >
/bin/sh -c "
- /usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD;
- /usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;
- /usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID;
- /usr/bin/mc mb myminio/$S3_BUCKET_NAME;
- /usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME;
- exit 0;
+ /usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD || exit 1;
+ /usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY 2>/dev/null || echo 'User already exists';
+ /usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID || exit 1;
+ /usr/bin/mc mb myminio/$S3_BUCKET_NAME 2>/dev/null || echo 'Bucket already exists';
+ /usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME || exit 1;
+ echo 'S3 configuration completed successfully';
" 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# use docker compose down --volumes to remove volumes declared in this file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
volumes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
minio: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
driver: local |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||
FROM node:20-alpine | ||||||
|
||||||
WORKDIR /usr/src/app | ||||||
|
||||||
COPY . . | ||||||
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. 💡 Verification agent 🧩 Analysis chainOptimize Docker context. Copying the entire project directory is inefficient. Consider using a .dockerignore file to exclude unnecessary files and directories. 🏁 Script executed: #!/bin/bash
# Check if .dockerignore exists and its contents
if [ -f .dockerignore ]; then
echo "Found .dockerignore:"
cat .dockerignore
else
echo ".dockerignore not found"
fi Length of output: 626 Optimize Docker build context and enhance container reliability.
Please update the Dockerfile accordingly. |
||||||
|
||||||
RUN apk upgrade --update-cache --available && \ | ||||||
apk add openssl && \ | ||||||
rm -rf /var/cache/apk/* | ||||||
RUN npm install -g pnpm@latest-9 | ||||||
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. 💡 Verification agent 🧩 Analysis chainConsider using a specific pnpm version. Using -RUN npm install -g pnpm@latest-9
+RUN npm install -g pnpm@9.x.x 🌐 Web query:
💡 Result: The latest stable version of pnpm 9 is v9.15.5, based on recent patch updates listed in the release notes[3]. This version includes security improvements and bug fixes such as:
While pnpm has since released major versions (currently v10.x), the final stable release in the v9 series remains v9.15.5 as of February 2025[3][6]. This version maintains compatibility with Node.js v18+ and includes all security patches backported from later major releases[4]. Citations:
Pin pnpm to a specific stable version (v9.15.5) in the Dockerfile To avoid potential issues from future breaking changes introduced in newer pnpm releases, please update the command in -RUN npm install -g pnpm@latest-9
+RUN npm install -g pnpm@9.15.5 📝 Committable suggestion
Suggested change
|
||||||
RUN pnpm install | ||||||
|
||||||
CMD [ "pnpm", "db:init" ] | ||||||
yoannfleurydev marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { pageUtils } from 'e2e/utils/pageUtils'; | ||
import { USER_EMAIL } from 'e2e/utils/users'; | ||
|
||
import { env } from '@/env.mjs'; | ||
import { ROUTES_ACCOUNT } from '@/features/account/routes'; | ||
import { ROUTES_APP } from '@/features/app/routes'; | ||
import locales from '@/locales'; | ||
|
||
test.beforeEach('Login to the app', async ({ page }) => { | ||
const utils = pageUtils(page); | ||
|
||
await utils.loginApp({ email: USER_EMAIL }); | ||
await page.waitForURL( | ||
`${env.NEXT_PUBLIC_BASE_URL}${ROUTES_APP.root() || '/'}**` | ||
); | ||
await expect(page.getByTestId('app-layout')).toBeVisible(); | ||
}); | ||
test.describe('Avatar upload flow', () => { | ||
test('Upload an avatar', async ({ page }) => { | ||
await expect(page.getByTestId('avatar-account')).toBeVisible(); | ||
|
||
await page.getByTestId('avatar-account').click(); | ||
|
||
await page.waitForURL(`**${ROUTES_ACCOUNT.app.root()}`); | ||
await expect( | ||
page.getByText(locales.en.account.data.avatar.placeholder) | ||
).toBeVisible(); | ||
|
||
const fileChooserPromise = page.waitForEvent('filechooser'); | ||
|
||
await page.getByText(locales.en.account.data.avatar.placeholder).click(); | ||
|
||
const fileChooser = await fileChooserPromise; | ||
await fileChooser.setFiles('./public/android-chrome-192x192.png'); | ||
|
||
await page | ||
.getByRole('button', { name: locales.en.account.profile.actions.update }) | ||
.first() | ||
.click(); | ||
|
||
await expect( | ||
page.locator('a[data-testid="avatar-account"] > img') | ||
).toHaveAttribute('src'); | ||
}); | ||
}); |
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.
💡 Verification agent
❓ Verification inconclusive
Postgres Healthcheck Variable Mismatch
The healthcheck command currently uses
$DOCKER_DATABASE_NAME
for the-U
flag, which expects a username. It should likely be$DOCKER_DATABASE_USERNAME
to correctly check connectivity.Critical Issue: Postgres Healthcheck Environment Variable
The healthcheck command in
docker-compose.yml
is incorrectly using$DOCKER_DATABASE_NAME
for the-U
flag, which requires a username. This should be replaced with$DOCKER_DATABASE_USERNAME
to ensure that the healthcheck correctly verifies connectivity.📝 Committable suggestion