Skip to content

Commit

Permalink
fix(docker): built index.js is now app.js when built by tsup
Browse files Browse the repository at this point in the history
  • Loading branch information
ADRFranklin committed May 10, 2024
1 parent 46fce15 commit 8738a36
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,38 @@ COPY . .
RUN yarn workspaces focus --all && \
yarn workspace frontend run build && \
yarn workspace api run build:prod && \
npx pkg . --no-bytecode --public-packages \"*\" --public --targets node18-alpine-x64
chmod -R u=rwX,go=rX /build/pkg

FROM scratch
FROM alpine

# Set enviornment variables for the app
ENV APP_DIR="/app"
ENV VIEWS_FOLDER="/app/views"
ENV DATA_FOLDER="/data"

# Install needed dependencies to get the image setup and then remove the cache
RUN apk add --no-cache \
shadow \
wget \
bash \
nodejs && \
# Remove package cache
rm -rf /var/cache/apk/* && \
rm -rf /tmp/*

# Create petio user, group and create folders with permissions
RUN groupadd -g 1000 petio && \
useradd -r -u 1000 -g petio petio && \
# Make sure the app directory exists and has the correct permissions
mkdir -p /app && chown petio:petio /app

# Copy all the build files from both frontend and backend
COPY --from=builder --chown=petio:petio --chmod=0755 /build/node_modules/napi-nanoid-linux-x64-musl/napi-nanoid.linux-x64-musl.node /app
COPY --from=builder --chown=petio:petio --chmod=0755 /build/pkg/frontend/build /app/views/frontend
COPY --from=builder --chown=petio:petio --chmod=0755 /build/dist/api/index.js /app/index.js
COPY --from=builder --chown=petio:petio --chmod=0755 /build/dist/api/app.js /app/index.js
COPY ./scripts/docker /

# Give our init script permission to be executed
RUN chmod +x /init.sh

# Makes sure we are in the app folder from now on
WORKDIR /app
Expand Down

0 comments on commit 8738a36

Please sign in to comment.