Skip to content

Commit

Permalink
chore: Update Dockerfile and README.md
Browse files Browse the repository at this point in the history
Update Dockerfile to copy the source code from the "prerelease" stage and include the tsconfig.json file. Also, update the README.md file to reflect the correct command for running the Docker image.
  • Loading branch information
kerolloz committed Jun 20, 2024
1 parent 8ca17b5 commit 299fb22
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/index.ts .
COPY --chown=bun:bun --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/src ./src
COPY --from=prerelease /usr/src/app/package.json .
COPY --from=prerelease /usr/src/app/tsconfig.json .

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "index.ts" ]
CMD [ "bun", "start" ]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ npm run build # Ensure TypeScript is happy :)

## Docker

Before building the image, you must create a `.env` file with the same variables as above.
Before running the image, you must create a `.env` file with the same variables as above.

```bash
docker build -t my-super-awesome-api .
docker run -p 5000:5000 my-super-awesome-api
docker run -p 5000:5000 --env-file=.env -it --network=host my-super-awesome-api # use --network=host for local development
```
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import authenticate from './lib/authenticate';
import { SWAGGER_ROUTE, registerSwagger } from './lib/swagger';
import { registerAllRoutes } from './routes';

const app = fastify();
const app = fastify({ pluginTimeout: 0 });

app.register(cors);
app.register(helmet);
Expand Down
2 changes: 1 addition & 1 deletion src/mailer/base.mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export abstract class BaseMailer {
.then(() =>
console.log(`An email was sent to ${JSON.stringify(this.msg.to)}`),
)
.catch(console.error);
.catch((err) => console.error('Failed to send email!', err));
}
}

0 comments on commit 299fb22

Please sign in to comment.