Skip to content

Commit

Permalink
Add users admin page and convert from Vue2 to Vue3 to allow for local…
Browse files Browse the repository at this point in the history
… user management.

Rewrote Dockerfile as architecture agnostic.
Dockerfile: npm build should no longer contain sourcemaps
Dockerfile: reverted back to recommended method for changing vhost directory
Dockerfile: curl extension comes with the php image, so this was removed.
Dockerfile: use recommended production php.ini file
Docker: container will crash loop if you don't provide APP_KEY, which is fine because you won't get a workable container without it.
  • Loading branch information
mosen committed Jan 18, 2024
1 parent 0f6ac1d commit 13c48d3
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 186 deletions.
51 changes: 20 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM node:20.10 as frontend
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN npm install && npm run build
RUN npm install && NODE_ENV=production npm run build

FROM php:8.3-apache
MAINTAINER MunkiReport PHP Team <munkireport@noreply.users.github.com>
Expand All @@ -10,13 +10,14 @@ LABEL architecture="x86_64" \
io.k8s.description="" \
License="MIT" \
version="v6.0.0-alpha"

#RUN arch="$(dpkg --print-architecture)" && args="--with-libdir=lib/x86_64-linux-gnu/" && \
# case "$arch" in \
# *arm*) args="" ;; \
# esac && \
# docker-php-ext-configure ldap "$args" && \
# docker-php-ext-install -j$(nproc) curl pdo_mysql soap ldap zip
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp
ENV APP_DIR /var/munkireport
ENV AUTH_METHODS LOCAL
ENV APP_URL http://localhost:8080
#ENV APP_ENV production
ENV LOG_CHANNEL stderr
ENV APACHE_DOCUMENT_ROOT=/var/munkireport/public

RUN apt-get update && \
apt-get install --no-install-recommends -y libldap2-dev \
Expand All @@ -28,51 +29,39 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
docker-php-ext-install -j$(nproc) curl pdo_mysql soap ldap zip opcache

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /tmp

ENV APP_DIR /var/munkireport
ENV APACHE_DOCUMENT_ROOT /var/munkireport/public
ENV AUTH_METHODS LOCAL
ENV APP_URL http://localhost:8080
ENV LOG_CHANNEL stderr
RUN docker-php-ext-configure ldap && \
docker-php-ext-install -j$(nproc) pdo_mysql soap ldap zip opcache
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY --chown=www-data:www-data . $APP_DIR
COPY --chown=www-data:www-data --from=frontend /usr/src/app/public/ $APACHE_DOCUMENT_ROOT/
COPY --chown=www-data:www-data --from=frontend /usr/src/app/public/ /var/munkireport/public/
WORKDIR $APP_DIR

COPY --from=composer:2.6 /usr/bin/composer /usr/local/bin/composer
COPY build/composer-local.example.json $APP_DIR/composer.local.json

USER www-data

RUN composer install --no-dev && \
composer dumpautoload -o && \
composer clear-cache

# You should not use this directory for SQLite as Laravel defines one. However, it is provided for backwards compatibility.
# Please use database/database.sqlite in future.
RUN mkdir -p app/db && \
touch app/db/db.sqlite

RUN php please migrate
touch app/db/db.sqlite

RUN chown -R www-data app/db storage
RUN chown -R www-data:www-data storage

RUN cp .env.example .env
RUN php please ziggy:generate --types

RUN rm -rf /var/www/html && \
ln -s /var/munkireport/public /var/www/html

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN sed -i 's/ServerTokens OS/ServerTokens Prod/' /etc/apache2/conf-available/security.conf

RUN sed -i 's/ServerSignature On/ServerSignature Off/' /etc/apache2/conf-available/security.conf
RUN sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf

RUN a2enmod rewrite
COPY build/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint

# Some systems restrict the usage of privileged (low) ports or running as UID/GID 0
USER www-data
EXPOSE 8080
1 change: 1 addition & 0 deletions app/lib/munkireport/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ protected function addCoreModules(): void
'system.database' => ['i18n' => 'system.database.menu_link', 'url' => url('/system/database')],
'widget.gallery' => ['i18n' => 'widget.gallery', 'url' => url('/system/widgets')],
'module_marketplace' => ['i18n' => 'module_marketplace.module_marketplace', 'url' => url('/module_marketplace')],
'users' => ['i18n' => 'users', 'url' => url('/admin/users')],
]
];
}
Expand Down
3 changes: 3 additions & 0 deletions build/docker-php-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function preflight() {
php please key:generate --show

echo "Please include the base64 portion, eg: APP_KEY=base64:aabbbcc"
echo "The container will exit in 5 seconds, because running without an APP_KEY does not leave you with a functional installation."
sleep 5
exit 1
else
echo "APP_KEY supplied. Not generating an APP_KEY."
fi
Expand Down
85 changes: 0 additions & 85 deletions resources/_vue/components/UsersList.vue

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,59 @@
<script lang="ts" setup>
import { defineProps } from 'vue'
import { useFetch } from '@vueuse/core'
import {useForm} from "@inertiajs/vue3";
import type { User } from '@/types.ts'
export interface Props {
user?: {
data: User
}
}
export interface FormData {
name: string;
display_name: string;
email: string;
locale?: string;
objectguid?: string;
}
const props = defineProps<Props>()
const { error, data, isFetching } = useFetch(`/api/v6/users/${props.userId}`).get().json()
const form = useForm<FormData>({
// name: props.user.name,
// display_name: props.user.data.display_name,
// email: props.user.data.email,
// locale: props.user.data.locale,
// objectguid: props.user.data.objectguid,
})
</script>

<template>
<div class="panel panel-default">
<div class="panel-body">
<form v-if="user.id">
<form v-if="props.user">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" v-model="user.name" />
<input type="text" class="form-control" id="username" v-model="form.name" />
</div>
<div class="form-group">
<label for="displayName">Display Name</label>
<input type="text" class="form-control" id="displayName" v-model="user.display_name"
<input type="text" class="form-control" id="displayName" v-model="form.display_name"
placeholder="A full name to display instead of the username" />
</div>
<div class="form-group">
<label for="email">E-mail</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" class="form-control" id="email" v-model="user.email" />
<input type="text" class="form-control" id="email" v-model="form.email" />
</div>
<span class="help-block">This does not need to be a valid address, but it does need to be unique. It will be
used for logging in.</span>
</div>
<div class="form-group">
<label for="locale">Preferred Locale</label>
<select id="locale" v-model="user.locale">
<select id="locale" v-model="form.locale">
<option disabled value="">Please select one</option>
<option value="en_US">English (en_US)</option>
<option value="de_DE">Deutsch (de_DE)</option>
Expand All @@ -31,79 +62,17 @@
</div>
<div class="form-group">
<label for="objectguid">Other System Unique ID</label>
<input readonly type="text" class="form-control" id="objectguid" :value="user.objectguid" />
<input readonly type="text" class="form-control" id="objectguid" :value="form.objectguid" />
</div>
<div class="alert alert-warning" role="alert" v-if="user.objectguid">
<div class="alert alert-warning" role="alert" v-if="form.objectguid">
This user has an ID set from another system or SSO login.
If you modify the username or e-mail they may not be able to log in.
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" @click.prevent="update">Update</button>
</div>
</form>

<span v-else>No user selected</span>
</div>
</div>
</template>

<script>
export default {
name: "UserForm",
props: ['userId'],
data() {
return {
id: this.userId,
error: null,
loading: false,
user: {
objectguid: "",
name: "",
display_name: "",
email: "",
locale: "",
}
}
},
mounted() {
this.loading = true;
return fetch("/api/v6/users/" + this.userId)
.then((response) => {
return response.json();
})
.then((data) => {
this.user = data.data;
})
.catch((e) => {
this.error = e.message;
})
.finally(() => {
this.loading = false;
});
},
updated() {
this.loading = true;
return fetch("/api/v6/users/" + this.userId)
.then((response) => {
return response.json();
})
.then((data) => {
this.user = data.data;
})
.catch((e) => {
this.error = e.message;
})
.finally(() => {
this.loading = false;
});
},
methods: {
update: () => {
console.log('update user');
},
},
}
</script>

<style scoped>
</style>
Loading

0 comments on commit 13c48d3

Please sign in to comment.