Skip to content

Commit

Permalink
Add working Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
CPlusPatch committed Nov 27, 2023
1 parent 8b442c2 commit 2c82cff
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ helm-charts
.editorconfig
.idea
coverage*
uploads
logs
27 changes: 18 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1.0.13-alpine as base
FROM oven/bun:1.0.14-alpine as base
WORKDIR /usr/src/app

RUN apk add vips-dev
# Required for Prisma to work
COPY --from=node:18-alpine /usr/local/bin/node /usr/local/bin/node

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
Expand All @@ -13,23 +17,28 @@ RUN cd /temp/dev && bun install --frozen-lockfile
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM install AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
RUN cd /temp/prod && bun install --frozen-lockfile --production.

# copy production dependencies and source code into final image
FROM base AS release

# Create app directory
RUN mkdir -p /app
COPY --from=install /temp/prod/node_modules /app/node_modules
COPY --from=prerelease /usr/src/app /app
COPY . /app

LABEL org.opencontainers.image.authors "Gaspard Wierzbinski (https://cpluspatch.dev)"
LABEL org.opencontainers.image.source "https://github.com/lysand-org/lysand"
LABEL org.opencontainers.image.vendor "Lysand Org"
LABEL org.opencontainers.image.licenses "AGPL-3.0"
LABEL org.opencontainers.image.title "Lysand Server"
LABEL org.opencontainers.image.description "Lysand Server docker image"

# run the app
USER bun
RUN bunx prisma generate
# Remove Node
USER root
RUN rm /usr/local/bin/node
USER bun
ENTRYPOINT [ "bun", "run", "index.ts" ]
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ database = "lysand"
host = "localhost"
post = 6379
password = ""
database = 0
# database = 0

[http]
base_url = "https://lysand.social"
Expand Down
2 changes: 1 addition & 1 deletion database/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const federationQueue = new Queue("federation", {
host: config.redis.queue.host,
port: config.redis.queue.port,
password: config.redis.queue.password,
db: config.redis.queue.database,
db: config.redis.queue.database || undefined,
},
});

Expand Down
2 changes: 1 addition & 1 deletion database/entities/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const federationWorker = new Worker(
host: config.redis.queue.host,
port: config.redis.queue.port,
password: config.redis.queue.password,
db: config.redis.queue.database,
db: config.redis.queue.database || undefined,
},
removeOnComplete: {
count: 400,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"jsonld": "^8.3.1",
"marked": "^9.1.2",
"prisma": "latest",
"sharp": "^0.32.6"
"semver": "^7.5.4",
"sharp": "^0.33.0-rc.2"
}
}
4 changes: 2 additions & 2 deletions utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ConfigType {
host: string;
port: number;
password: string;
database: number;
database: number | null;
};
};

Expand Down Expand Up @@ -159,7 +159,7 @@ export const configDefaults: ConfigType = {
host: "localhost",
port: 6379,
password: "",
database: 0,
database: null,
},
},
instance: {
Expand Down

0 comments on commit 2c82cff

Please sign in to comment.