Skip to content

Commit 6e33350

Browse files
authored
fix: imgproxy volume binding (#754)
1 parent 23559aa commit 6e33350

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.docker/docker-compose-infra.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ services:
151151
ports:
152152
- '50020:8080'
153153
volumes:
154-
- ./data:/images/data
154+
- ${PWD}/data:${PWD}/data
155155
environment:
156156
- IMGPROXY_WRITE_TIMEOUT=20
157157
- IMGPROXY_READ_TIMEOUT=20
158158
- IMGPROXY_REQUESTS_QUEUE_SIZE=24
159-
- IMGPROXY_LOCAL_FILESYSTEM_ROOT=/images
159+
- IMGPROXY_LOCAL_FILESYSTEM_ROOT=/
160160
- IMGPROXY_USE_ETAG=true
161161
- IMGPROXY_ENABLE_WEBP_DETECTION=true
162162
- IMGPROXY_PRESETS=default=width:3000/height:8192

src/test/common.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import app from '../admin-app'
33
import { S3Backend } from '../storage/backend'
44
import { Queue } from '@internal/queue'
55
import { isS3Error } from '@internal/errors'
6+
import path from 'path'
67

78
export const adminApp = app({})
89

910
const ENV = process.env
11+
const projectRoot = path.join(__dirname, '..', '..')
1012

1113
export function useMockQueue() {
1214
const queueSpy: jest.SpyInstance | undefined = undefined
@@ -78,7 +80,9 @@ export function useMockObject() {
7880
contentLength: 3746,
7981
})
8082

81-
jest.spyOn(S3Backend.prototype, 'privateAssetUrl').mockResolvedValue('local:///data/sadcat.jpg')
83+
jest
84+
.spyOn(S3Backend.prototype, 'privateAssetUrl')
85+
.mockResolvedValue(`local:///${projectRoot}/data/sadcat.jpg`)
8286
})
8387

8488
afterEach(() => {

src/test/render-routes.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ dotenv.config({ path: '.env.test' })
1414
const { imgProxyURL, jwtSecret } = getConfig()
1515
let appInstance: FastifyInstance
1616

17+
const projectRoot = path.join(__dirname, '..', '..')
18+
1719
describe('image rendering routes', () => {
1820
beforeAll(async () => {
1921
await fs.mkdir(path.join(__dirname, '..', '..', 'data'), { recursive: true })
@@ -51,7 +53,7 @@ describe('image rendering routes', () => {
5153
expect(response.statusCode).toBe(200)
5254
expect(S3Backend.prototype.privateAssetUrl).toBeCalledTimes(1)
5355
expect(axiosSpy).toBeCalledWith(
54-
'/public/height:100/width:100/resizing_type:fill/plain/local:///data/sadcat.jpg',
56+
`/public/height:100/width:100/resizing_type:fill/plain/local:///${projectRoot}/data/sadcat.jpg`,
5557
{ responseType: 'stream', signal: expect.any(AbortSignal) }
5658
)
5759
})
@@ -69,7 +71,7 @@ describe('image rendering routes', () => {
6971
expect(response.statusCode).toBe(200)
7072
expect(S3Backend.prototype.privateAssetUrl).toBeCalledTimes(1)
7173
expect(axiosSpy).toBeCalledWith(
72-
'/public/height:100/width:100/resizing_type:fill/plain/local:///data/sadcat.jpg',
74+
`/public/height:100/width:100/resizing_type:fill/plain/local:///${projectRoot}/data/sadcat.jpg`,
7375
{ responseType: 'stream', signal: expect.any(AbortSignal) }
7476
)
7577
})
@@ -112,7 +114,7 @@ describe('image rendering routes', () => {
112114
expect(response.statusCode).toBe(200)
113115
expect(S3Backend.prototype.privateAssetUrl).toBeCalledTimes(1)
114116
expect(axiosSpy).toBeCalledWith(
115-
'/public/height:100/width:100/resizing_type:fit/plain/local:///data/sadcat.jpg',
117+
`/public/height:100/width:100/resizing_type:fit/plain/local:///${projectRoot}/data/sadcat.jpg`,
116118
{ responseType: 'stream', signal: expect.any(AbortSignal) }
117119
)
118120
})
@@ -159,7 +161,7 @@ describe('image rendering routes', () => {
159161
expect(response.statusCode).toBe(200)
160162
expect(S3Backend.prototype.privateAssetUrl).toBeCalledTimes(1)
161163
expect(axiosSpy).toBeCalledWith(
162-
'/public/height:100/width:100/resizing_type:fit/plain/local:///data/sadcat.jpg',
164+
`/public/height:100/width:100/resizing_type:fit/plain/local:///${projectRoot}/data/sadcat.jpg`,
163165
{ responseType: 'stream', signal: expect.any(AbortSignal) }
164166
)
165167
})

0 commit comments

Comments
 (0)