Skip to content

Commit 55d96ad

Browse files
committed
fix entrypoint
1 parent 066986e commit 55d96ad

3 files changed

Lines changed: 45 additions & 4 deletions

File tree

docker/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ ENV \
5959
PIP_NO_CACHE_DIR=off \
6060
PIP_DISABLE_PIP_VERSION_CHECK=on \
6161
PIP_DEFAULT_TIMEOUT=100
62+
ENV \
63+
PORT=8000
6264

6365
# Get build artifact wheel and install it respecting dependency versions
6466
WORKDIR $APP_PATH
6567
COPY --from=build $APP_PATH/dist/*.whl ./
6668
COPY --from=build $APP_PATH/constraints.txt ./
6769
RUN pip install ./$APP_NAME*.whl --constraint constraints.txt
68-
CMD ["uvicorn", "beerlog.api:api", "--host=0.0.0.0","--port=8000","--reload"]
70+
71+
COPY ./docker/entrypoint.sh /entrypoint.sh
72+
RUN chmod +x /entrypoint.sh
73+
ENTRYPOINT ["/entrypoint.sh"]
74+
CMD ["uvicorn", "beerlog.api:api", "--host=0.0.0.0","--port=$PORT"]

docker/entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# You can put other setup logic here
6+
# Evaluating passed command:
7+
eval "exec $@"

docs/day2.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ async def add_beer(beer_in: BeerIn, response: Response):
176176

177177
## Rodando em um container
178178

179-
Criando o Dockerfile
179+
Criando o Dockerfile em `docker/Dockerfile`
180180

181181

182182
```dockerfile
@@ -241,20 +241,48 @@ ENV \
241241
PIP_NO_CACHE_DIR=off \
242242
PIP_DISABLE_PIP_VERSION_CHECK=on \
243243
PIP_DEFAULT_TIMEOUT=100
244+
ENV \
245+
PORT=8000
244246

245247
# Get build artifact wheel and install it respecting dependency versions
246248
WORKDIR $APP_PATH
247249
COPY --from=build $APP_PATH/dist/*.whl ./
248250
COPY --from=build $APP_PATH/constraints.txt ./
249251
RUN pip install ./$APP_NAME*.whl --constraint constraints.txt
250-
CMD ["uvicorn", "beerlog.api:api", "--host=0.0.0.0","--port=8000","--reload"]
252+
253+
COPY ./docker/entrypoint.sh /entrypoint.sh
254+
RUN chmod +x /entrypoint.sh
255+
ENTRYPOINT ["/entrypoint.sh"]
256+
CMD ["uvicorn", "beerlog.api:api", "--host=0.0.0.0","--port=$PORT"]
257+
```
258+
259+
e um `docker/entrypoint.sh`
260+
261+
262+
```sh
263+
#!/bin/sh
264+
265+
set -e
266+
267+
# You can put other setup logic here
268+
# Evaluating passed command:
269+
eval "exec $@"
251270
```
252271

272+
Para fazer o build.
253273

254274
```bash
255275
docker build -t beerlog/prod --file docker/Dockerfile .
276+
```
277+
278+
Para rodar
279+
280+
```bash
256281
# e
257-
docker run -p 8000:8000 rochacbruno/beerlog
282+
docker run -p 8000:8000 beerlog/prod
283+
284+
# ou para alterar a porta
285+
docker run -p 8000:5000 -e PORT=5000 beerlog/prod
258286
```
259287

260288
Para a imagem de development

0 commit comments

Comments
 (0)