Reduce docker api image size, fix issues

This commit is contained in:
Julien Nahum 2024-08-28 15:20:39 +02:00
parent 79d3dd7888
commit 2503595786
8 changed files with 989 additions and 992 deletions

View File

@ -40,13 +40,11 @@ class ProfileController extends Controller
'password.not_in' => "Please another password other than 'password'."
]);
ray('in', $request->password);
$user = $request->user();
$user->update([
'email' => $request->email,
'password' => bcrypt($request->password),
]);
ray($user);
Cache::forget('initial_user_setup_complete');
Cache::forget('max_user_id');

View File

@ -39,7 +39,8 @@
"stevebauman/purify": "*",
"tymon/jwt-auth": "*",
"vinkla/hashids": "*",
"fakerphp/faker": "^1.23"
"fakerphp/faker": "^1.23",
"spatie/laravel-ray": "*"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.0.0",
@ -50,8 +51,7 @@
"nunomaduro/collision": "*",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.4",
"spatie/laravel-ignition": "*",
"spatie/laravel-ray": "*"
"spatie/laravel-ignition": "*"
},
"config": {
"optimize-autoloader": true,

1846
api/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -236,9 +236,6 @@ test('make up a submission when polling without any submission', function () {
// Decode the response data
$responseData = $response->json()[0];
ray($responseData);
ray($responseData);
$this->assertNotEmpty($responseData['data']);
$this->assertTrue(count($responseData['data']) == 2);
});

View File

@ -1,22 +1,32 @@
<template>
<template>
<div class="flex flex-grow mt-6 mb-10">
<div class="w-full md:w-2/3 md:mx-auto md:max-w-md px-4">
<div class="m-10" v-if="loading">
<h3 class="my-6 text-center">
Please wait...
</h3>
<Loader class="h-6 w-6 mx-auto m-10" />
<template>
<div class="flex flex-grow mt-6 mb-10">
<div class="w-full md:w-2/3 md:mx-auto md:max-w-md px-4">
<div
v-if="loading"
class="m-10"
>
<h3 class="my-6 text-center">
Please wait...
</h3>
<Loader class="h-6 w-6 mx-auto m-10" />
</div>
<div class="m-6 flex flex-col items-center space-y-4" v-else>
<p class="text-center"> Unable to sign it at the moment. </p>
<v-button
:to="{ name: 'login' }"
>Back to login</v-button>
<div
v-else
class="m-6 flex flex-col items-center space-y-4"
>
<p class="text-center">
Unable to sign it at the moment.
</p>
<v-button
:to="{ name: 'login' }"
>
Back to login
</v-button>
</div>
</div>
</div>
</div>
</template>
</template>
</template>
<script setup>
@ -26,12 +36,10 @@ const authStore = useAuthStore()
const workspacesStore = useWorkspacesStore()
const formsStore = useFormsStore()
const logEvent = useAmplitude().logEvent
const loading = ref(true);
const loading = ref(true)
definePageMeta({
alias: [
'/oauth/:provider/callback'
]
alias: '/oauth/:provider/callback'
})
function handleCallback() {
@ -82,7 +90,7 @@ function handleCallback() {
}
}).catch(error => {
useAlert().error(error.response._data.message)
loading.value = false;
loading.value = false
})
}
onMounted(() => {

View File

@ -44,9 +44,7 @@ useOpnSeoMeta({
definePageMeta({
middleware: "auth",
alias: [
'/settings/connections/callback/:service'
]
alias: '/settings/connections/callback/:service'
})
const router = useRouter()

View File

@ -6,7 +6,7 @@ export const useFeatureFlagsStore = defineStore('feature_flags', () => {
async function fetchFlags() {
try {
const { data } = await useOpnApi('/content/feature-flags')
const { data } = await useOpnApi('content/feature-flags')
flags.value = data.value
} catch (error) {
console.error('Failed to fetch feature flags:', error)

View File

@ -2,50 +2,46 @@ FROM php:8.3-fpm
# syntax=docker/dockerfile:1.3-labs
RUN apt-get update && apt-get install -y libzip-dev libpng-dev postgresql-client libpq-dev && apt-get clean
RUN apt-get update && apt-get install -y \
libzip-dev \
libpng-dev \
postgresql-client \
libpq-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1
RUN docker-php-ext-install pdo pgsql pdo_pgsql gd bcmath zip && pecl install redis && docker-php-ext-enable redis
RUN docker-php-ext-install pdo pgsql pdo_pgsql gd bcmath zip \
&& pecl install redis \
&& docker-php-ext-enable redis
WORKDIR /usr/share/nginx/html/
ADD api/composer.json api/composer.lock api/artisan ./
# NOTE: The project would build more reliably if all php files were added before running
# composer install. This would though introduce a dependency which would cause every
# dependency to be re-installed each time any php file is edited. It may be necessary in
# future to remove this 'optimisation' by moving the `RUN composer install` line after all
# the following ADD commands.
# Combine multiple ADD commands into one
COPY api/composer.json api/composer.lock api/artisan ./
COPY api/app ./app
COPY api/bootstrap ./bootstrap
COPY api/config ./config
COPY api/database ./database
COPY api/public ./public
COPY api/routes ./routes
COPY api/tests ./tests
COPY api/resources ./resources
COPY api/storage ./storage
# Running artisan requires the full php app to be installed so we need to remove the
# post-autoload command from the composer file if we want to run composer without
# adding a dependency to all the php files.
RUN sed 's_@php artisan package:discover_/bin/true_;' -i composer.json
ADD api/app/helpers.php app/helpers.php
RUN composer install --ignore-platform-req=php
ADD api/app ./app
ADD api/bootstrap ./bootstrap
ADD api/config ./config
ADD api/database ./database
ADD api/public public
ADD api/routes routes
ADD api/tests tests
ADD api/resources resources
ADD api/storage ./storage
RUN chmod -R 775 storage && chown -R www-data:www-data storage
# Manually run the command we deleted from composer.json earlier
RUN php artisan package:discover --ansi
COPY docker/php-fpm-entrypoint /usr/local/bin/opnform-entrypoint
RUN chmod a+x /usr/local/bin/*
# Create necessary directories and set permissions
RUN mkdir -p storage/framework/sessions storage/framework/views storage/framework/cache \
RUN sed 's_@php artisan package:discover_/bin/true_;' -i composer.json \
&& composer install --ignore-platform-req=php --no-dev --optimize-autoloader \
&& composer clear-cache \
&& php artisan package:discover --ansi \
&& chmod -R 775 storage \
&& chown -R www-data:www-data storage \
&& mkdir -p storage/framework/sessions storage/framework/views storage/framework/cache \
&& chown -R www-data:www-data storage \
&& chmod -R 775 storage
ENTRYPOINT [ "/usr/local/bin/opnform-entrypoint" ]
CMD php-fpm
COPY docker/php-fpm-entrypoint /usr/local/bin/opnform-entrypoint
RUN chmod a+x /usr/local/bin/*
ENTRYPOINT ["/usr/local/bin/opnform-entrypoint"]
CMD ["php-fpm"]