feat: Update Dockerfile and scripts for improved build process and cron job functionality
This commit is contained in:
parent
db08433a01
commit
ef65994a82
5 changed files with 115 additions and 58 deletions
24
.gitignore
vendored
24
.gitignore
vendored
|
|
@ -1 +1,25 @@
|
||||||
.env
|
.env
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
Icon[]
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
35
Dockerfile
35
Dockerfile
|
|
@ -1,12 +1,6 @@
|
||||||
FROM oven/bun:alpine
|
FROM oven/bun:alpine as build
|
||||||
LABEL maintainer="@imnya"
|
LABEL maintainer="@imnya"
|
||||||
|
|
||||||
# Set timezone to Asia/Seoul
|
|
||||||
RUN apk add --no-cache tzdata \
|
|
||||||
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
|
|
||||||
&& echo "Asia/Seoul" > /etc/timezone \
|
|
||||||
&& apk del tzdata
|
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
COPY app /code/app
|
COPY app /code/app
|
||||||
COPY .env /code/app/.env
|
COPY .env /code/app/.env
|
||||||
|
|
@ -19,11 +13,38 @@ RUN mkdir -p /code/app/temp
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN bun install
|
RUN bun install
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
RUN bun build index.ts --compile --minify --outfile ./run
|
||||||
|
|
||||||
|
FROM oven/bun:alpine as runner
|
||||||
|
LABEL maintainer="@imnya"
|
||||||
|
|
||||||
|
# Set the working directory
|
||||||
|
WORKDIR /code
|
||||||
|
RUN mkdir -p /code/app
|
||||||
|
|
||||||
|
# Copy the built files from the build stage
|
||||||
|
COPY --from=build /code/app/run /code/app/run
|
||||||
|
COPY --from=build /code/app/template /code/app/template
|
||||||
|
COPY --from=build /code/app/.env /code/app/.env
|
||||||
|
COPY --from=build /code/app/cron /code/app/cron
|
||||||
|
COPY --from=build /code/app/run.sh /code/app/run.sh
|
||||||
|
|
||||||
|
RUN mkdir -p /code/app/temp
|
||||||
|
|
||||||
|
# Set timezone to Asia/Seoul
|
||||||
|
RUN apk add --no-cache tzdata \
|
||||||
|
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \
|
||||||
|
&& echo "Asia/Seoul" > /etc/timezone \
|
||||||
|
&& apk del tzdata
|
||||||
|
|
||||||
# Cron job
|
# Cron job
|
||||||
RUN apk add --no-cache curl
|
RUN apk add --no-cache curl
|
||||||
RUN curl -Lo /code/app/supercronic https://github.com/aptible/supercronic/releases/latest/download/supercronic-linux-amd64 \
|
RUN curl -Lo /code/app/supercronic https://github.com/aptible/supercronic/releases/latest/download/supercronic-linux-amd64 \
|
||||||
&& chmod +x /code/app/supercronic
|
&& chmod +x /code/app/supercronic
|
||||||
|
|
||||||
|
RUN curl -o /code/app/temp/vts.xlsx https://f.imnya.ng/.today.isangjeong/vts.xlsx
|
||||||
|
|
||||||
COPY cron /code/app/cron
|
COPY cron /code/app/cron
|
||||||
RUN chmod +x /code/app/cron
|
RUN chmod +x /code/app/cron
|
||||||
|
|
||||||
|
|
|
||||||
33
app/index.ts
33
app/index.ts
|
|
@ -1,22 +1,20 @@
|
||||||
import { CreateImage } from "./lib/image";
|
import { CreateImage } from "./lib/image";
|
||||||
import { Login, Upload } from "./lib/instagram";
|
import { Login, Upload } from "./lib/instagram";
|
||||||
|
|
||||||
console.time("🎉 | Done")
|
console.time("🎉 | Done");
|
||||||
|
|
||||||
|
async function main() {
|
||||||
console.time("🔓 | Instagram login");
|
console.time("🔓 | Instagram login");
|
||||||
|
|
||||||
await Login()
|
try {
|
||||||
.then((data) => {
|
const data = await Login();
|
||||||
console.log("✨ | Instagram login successful");
|
console.log("✨ | Instagram login successful");
|
||||||
console.log(`🤔 | Login as ${data.currentUser.full_name}`);
|
console.log(`🤔 | Login as ${data.currentUser.full_name}`);
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
console.error("❌ | Instagram login failed:", error);
|
console.error("❌ | Instagram login failed:", error);
|
||||||
})
|
} finally {
|
||||||
.finally(() => {
|
|
||||||
console.timeEnd("🔓 | Instagram login");
|
console.timeEnd("🔓 | Instagram login");
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
let YYMMDD = "";
|
let YYMMDD = "";
|
||||||
|
|
||||||
|
|
@ -42,7 +40,14 @@ if (tomorrow.getDate() === 1) {
|
||||||
console.timeEnd("📅 | Create Post Schedule");
|
console.timeEnd("📅 | Create Post Schedule");
|
||||||
|
|
||||||
console.time("📤 | Upload Post Schedule");
|
console.time("📤 | Upload Post Schedule");
|
||||||
await Upload.Post(`./temp/schedule-${new Date().getFullYear()}-${new Date().getMonth() + 1}.png`, `#인천상정중학교 #상정중학교 #학사일정 \n${new Date().getFullYear()}년도 ${new Date().getMonth() + 1}월 학사 일정`);
|
await Upload.Post(
|
||||||
|
`./temp/schedule-${new Date().getFullYear()}-${
|
||||||
|
new Date().getMonth() + 1
|
||||||
|
}.png`,
|
||||||
|
`#인천상정중학교 #상정중학교 #학사일정 \n${new Date().getFullYear()}년도 ${
|
||||||
|
new Date().getMonth() + 1
|
||||||
|
}월 학사 일정`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.time("📷 | Create Post Image");
|
console.time("📷 | Create Post Image");
|
||||||
|
|
@ -54,7 +59,10 @@ try {
|
||||||
console.timeEnd("📱 | Create Story Image");
|
console.timeEnd("📱 | Create Story Image");
|
||||||
|
|
||||||
console.time("📤 | Upload Post");
|
console.time("📤 | Upload Post");
|
||||||
await Upload.Post(`./temp/${YYMMDD}.png`, `#인천상정중학교 #상정중학교 #급식 \n${YYMMDD}일자 급식`);
|
await Upload.Post(
|
||||||
|
`./temp/${YYMMDD}.png`,
|
||||||
|
`#인천상정중학교 #상정중학교 #급식 \n${YYMMDD}일자 급식`
|
||||||
|
);
|
||||||
console.timeEnd("📤 | Upload Post");
|
console.timeEnd("📤 | Upload Post");
|
||||||
|
|
||||||
console.time("📤 | Upload Story");
|
console.time("📤 | Upload Story");
|
||||||
|
|
@ -65,3 +73,6 @@ try {
|
||||||
} finally {
|
} finally {
|
||||||
console.timeEnd("🎉 | Done");
|
console.timeEnd("🎉 | Done");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
cd /code/app
|
cd /code/app
|
||||||
|
|
||||||
bun ./index.ts
|
./run
|
||||||
1
cron
1
cron
|
|
@ -1 +1,2 @@
|
||||||
0 22 * * * /code/app/run.sh >> /code/app/temp/run-$(date +%Y%m%d-%H%M%S).log 2>&1
|
0 22 * * * /code/app/run.sh >> /code/app/temp/run-$(date +%Y%m%d-%H%M%S).log 2>&1
|
||||||
|
0 23 * * 0 curl -o /code/app/temp/vts.xlsx https://f.imnya.ng/.today.isangjeong/vts.xlsx
|
||||||
Loading…
Add table
Add a link
Reference in a new issue