Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
RyosukeDTomita committed Aug 28, 2024
1 parent e3a646e commit 3794fe6
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: integration-test
on:
push:
paths:
- .github/workflows/integration-test.yaml
- src/**/*.py

defaults:
run:
shell: bash

env:
PYTHON_VERSION: 3.12.4

jobs:
run-pytest:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
# checkout repository to runner
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: build image
run: |
docker buildx bake
- name: integration test
run: |
docker compose up hacking_lab_app &
docker compose run my_portscanner_app -sS 172.18.0.3
24 changes: 24 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,27 @@ services:
dockerfile: Dockerfile
image: my_portscanner:latest
container_name: my_portscanner-container
networks:
my_portscanner_default:
ipv4_address: 172.18.0.2

hacking_lab_app:
build:
context: ./hacking_lab
dockerfile: Dockerfile
image: hacking_lab:latest
container_name: hacking_lab_container
ports:
- 81:80
- 20022:22
networks:
my_portscanner_default:
ipv4_address: 172.18.0.3

networks:
my_portscanner_default:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.18.0.0/16
36 changes: 36 additions & 0 deletions hacking_lab/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM debian:bookworm-20240812-slim
ARG VERSION="0.0.0"
LABEL version="${VERSION}" \
author="RyosukeDTomita" \
docker_compose_build="docker buildx bake" \
docker_build="docker buildx build . -t hacking_lab" \
docker_compose_run="docker compose run hacking_lab_app" \
docker_run="docker run my_portscanner hakcking_lab"

# 環境変数の設定
ENV MYSQL_ROOT_PASSWORD=rootpassword
ENV MYSQL_USER=myuser
ENV MYSQL_PASSWORD=mypassword
ENV MYSQL_DATABASE=mydatabase

RUN <<EOF
apt-get update -y
apt-get install -y --no-install-recommends apache2 openssh-server
rm -rf /var/lib/apt/lists/*
EOF

# ssh settings
RUN <<EOF
mkdir /var/run/sshd
echo "root:root" | chpasswd # id:password
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config
EOF

COPY ./entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 22 80

CMD ["/entrypoint.sh"]
10 changes: 10 additions & 0 deletions hacking_lab/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
hacking_lab_app:
build:
context: .
dockerfile: Dockerfile
image: hacking_lab:latest
container_name: hacking_lab_container
ports:
- 81:80
- 20022:22
3 changes: 3 additions & 0 deletions hacking_lab/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
/etc/init.d/apache2 start & # backgroundで実行しないとsshdが起動できない。
/usr/sbin/sshd -D

0 comments on commit 3794fe6

Please sign in to comment.