This commit is contained in:
@@ -26,14 +26,7 @@ jobs:
|
|||||||
git fetch --depth=1 origin "${{ gitea.sha }}"
|
git fetch --depth=1 origin "${{ gitea.sha }}"
|
||||||
git checkout --detach FETCH_HEAD
|
git checkout --detach FETCH_HEAD
|
||||||
|
|
||||||
- name: Build test stage
|
- name: Test and build runtime image
|
||||||
run: |
|
|
||||||
docker build \
|
|
||||||
--target test \
|
|
||||||
--tag "${IMAGE_NAME}:test-${{ gitea.sha }}" \
|
|
||||||
.
|
|
||||||
|
|
||||||
- name: Build runtime image
|
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
--target runtime \
|
--target runtime \
|
||||||
|
|||||||
+5
-2
@@ -19,13 +19,16 @@ COPY app.py .
|
|||||||
FROM base AS test
|
FROM base AS test
|
||||||
COPY docker-compose.yml docker-compose.local.yml ./
|
COPY docker-compose.yml docker-compose.local.yml ./
|
||||||
COPY tests ./tests
|
COPY tests ./tests
|
||||||
RUN python -m unittest discover -s tests -v
|
RUN python -m unittest discover -s tests -v \
|
||||||
|
&& touch /tmp/tests-passed
|
||||||
|
|
||||||
# 実行用ステージ
|
# 実行用ステージ
|
||||||
FROM base AS runtime
|
FROM base AS runtime
|
||||||
|
|
||||||
# 非rootユーザーを作成
|
# 非rootユーザーを作成
|
||||||
RUN useradd --create-home --shell /bin/bash appuser \
|
COPY --from=test /tmp/tests-passed /tmp/tests-passed
|
||||||
|
RUN rm /tmp/tests-passed \
|
||||||
|
&& useradd --create-home --shell /bin/bash appuser \
|
||||||
&& chown -R appuser:appuser /app
|
&& chown -R appuser:appuser /app
|
||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user