mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #257 from lorenzomigliorero/fix/docker-compose-logs
fix: docker compose logs
This commit is contained in:
@@ -30,12 +30,14 @@ export const DockerLogs = dynamic(
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
appName: string;
|
appName: string;
|
||||||
|
appType: "stack" | "docker-compose";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ShowDockerLogsCompose = ({ appName }: Props) => {
|
export const ShowDockerLogsCompose = ({ appName, appType }: Props) => {
|
||||||
const { data } = api.docker.getContainersByAppNameMatch.useQuery(
|
const { data } = api.docker.getContainersByAppNameMatch.useQuery(
|
||||||
{
|
{
|
||||||
appName,
|
appName,
|
||||||
|
appType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!appName,
|
enabled: !!appName,
|
||||||
|
|||||||
@@ -156,7 +156,10 @@ const Service = (
|
|||||||
|
|
||||||
<TabsContent value="logs">
|
<TabsContent value="logs">
|
||||||
<div className="flex flex-col gap-4 pt-2.5">
|
<div className="flex flex-col gap-4 pt-2.5">
|
||||||
<ShowDockerLogsCompose appName={data?.appName || ""} />
|
<ShowDockerLogsCompose
|
||||||
|
appName={data?.appName || ""}
|
||||||
|
appType={data?.composeType || "docker-compose"}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,14 @@ export const dockerRouter = createTRPCRouter({
|
|||||||
getContainersByAppNameMatch: protectedProcedure
|
getContainersByAppNameMatch: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
|
appType: z
|
||||||
|
.union([z.literal("stack"), z.literal("docker-compose")])
|
||||||
|
.optional(),
|
||||||
appName: z.string().min(1),
|
appName: z.string().min(1),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
return await getContainersByAppNameMatch(input.appName);
|
return await getContainersByAppNameMatch(input.appName, input.appType);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getContainersByAppLabel: protectedProcedure
|
getContainersByAppLabel: protectedProcedure
|
||||||
|
|||||||
@@ -66,10 +66,18 @@ export const getConfig = async (containerId: string) => {
|
|||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getContainersByAppNameMatch = async (appName: string) => {
|
export const getContainersByAppNameMatch = async (
|
||||||
|
appName: string,
|
||||||
|
appType?: "stack" | "docker-compose",
|
||||||
|
) => {
|
||||||
try {
|
try {
|
||||||
|
const cmd =
|
||||||
|
"docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}}'";
|
||||||
|
|
||||||
const { stdout, stderr } = await execAsync(
|
const { stdout, stderr } = await execAsync(
|
||||||
`docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}}' | grep ${appName}`,
|
appType === "docker-compose"
|
||||||
|
? `${cmd} --filter='label=com.docker.compose.project=${appName}'`
|
||||||
|
: `${cmd} | grep ${appName}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user