Skip to content

Commit

Permalink
fix composer dependencies + remove composer lock
Browse files Browse the repository at this point in the history
  • Loading branch information
Murazaki committed Nov 9, 2024
1 parent 820b674 commit bf7453b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ FROM --platform=${BUILDARCH} node:lts AS frontend-build
ARG BUILDARCH
ARG BUILD_FRONTEND=0
ARG RUNTIME_UID
ARG RUNTIME_GID

ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
Expand Down Expand Up @@ -258,15 +259,22 @@ USER ${RUNTIME_UID}:${RUNTIME_GID}

# Install composer dependencies
# NOTE: we skip the autoloader generation here since we don't have all files avaliable (yet)
RUN --mount=type=cache,id=pixelfed-composer-${PHP_VERSION},sharing=locked,target=/cache/composer \
RUN --mount=type=cache,id=pixelfed-composer-${PHP_VERSION},sharing=locked,uid=${RUNTIME_UID},gid=${RUNTIME_GID},target=/cache/composer \
--mount=type=bind,source=composer.json,target=/var/www/composer.json \
--mount=type=bind,source=composer.lock,target=/var/www/composer.lock \
set -ex \
&& composer install --prefer-dist --no-autoloader --ignore-platform-reqs
&& composer update --prefer-dist --no-autoloader --ignore-platform-reqs --no-scripts

# Copy all other files over
COPY --chown=${RUNTIME_UID}:${RUNTIME_GID} . /var/www/

# Generate optimized autoloader now that we have all files around
RUN set -ex \
&& ENABLE_CONFIG_CACHE=false composer dump-autoload --optimize

# Now we can run the post-install scripts
RUN set -ex \
&& composer run-script post-update-cmd

#######################################################
# Runtime: base
#######################################################
Expand All @@ -286,13 +294,6 @@ COPY --link --from=composer-image /usr/bin/composer /usr/bin/composer
COPY --link --from=composer-and-src --chown=${RUNTIME_UID}:${RUNTIME_GID} /var/www /var/www
COPY --link --from=frontend-build --chown=${RUNTIME_UID}:${RUNTIME_GID} /var/www/public /var/www/public

#! Changing user to runtime user
USER ${RUNTIME_UID}:${RUNTIME_GID}

# Generate optimized autoloader now that we have all files around
RUN set -ex \
&& composer dump-autoload --optimize

USER root

# for detail why storage is copied this way, pls refer to https://github.com/pixelfed/pixelfed/pull/2137#discussion_r434468862
Expand Down
6 changes: 6 additions & 0 deletions app/Services/AccountService.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ public static function usernameToId($username)
if ($s->contains('@') && ! $s->startsWith('@')) {
$username = "@{$username}";
}
if(preg_match('/^@([^@]+)@'.preg_quote(config('pixelfed.domain.app')).'$/i', $username, $matches)) {
# The username is the fully qualified @[email protected] and the pixelfed site is example.com
# Normalize this username to just user
$username = $matches[1];
}

$profile = DB::table('profiles')
->whereUsername($username)
->first();
Expand Down

0 comments on commit bf7453b

Please sign in to comment.