Skip to content
Snippets Groups Projects
Commit ee4f3a89 authored by ludo8147's avatar ludo8147
Browse files

build images and start container

parent e9c1abda
No related branches found
No related tags found
No related merge requests found
Pipeline #69150 failed
......@@ -20,4 +20,8 @@ https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/key_
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc
\ No newline at end of file
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc
https://registry.terraform.io/providers/hashicorp/aws/3.74.2/docs/data-sources/ami
https://stackoverflow.com/questions/63899082/terraform-list-of-ami-specific-to-ubuntu-20-08-lts-aws
\ No newline at end of file
#Code aus GitHub Solution
FROM scratch
#https://manpages.ubuntu.com/manpages/jammy/man5/containers-dockerfile.5.html
FROM ubuntu
COPY ./artifact.bin /bin/webservice
ENV HOST 0.0.0.0
ENTRYPOINT [ "/bin/webservice" ]
CMD [ "" ]
\ No newline at end of file
ENTRYPOINT [ "/bin/webservice" ]
\ No newline at end of file
lucad@lucad:~/Documents/DevOps/tutorials/webservice$ GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o ./art
ifact.bin ./*.go
lucad@lucad:~/Documents/DevOps/tutorials/webservice$ cd build\ images\ \&\ start\ containers/
lucad@lucad:~/Documents/DevOps/tutorials/webservice/build images & start containers$ podman build --file ./C
ontainerfile --tag my-webservice:1.0.0 ./
STEP 1/5: FROM scratch
STEP 2/5: COPY ./artifact.bin /bin/webservice
--> 2cd5c65be9d
STEP 3/5: ENV HOST 0.0.0.0
--> 6b1d3bb71e2
STEP 4/5: ENTRYPOINT [ "/bin/webservice" ]
--> 0f645a51b6f
STEP 5/5: CMD [ "" ]
COMMIT my-webservice:1.0.0
--> 142d3985417
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman build --file ./Containerfile --tag webservice:latest ./
STEP 1/4: FROM ubuntu
STEP 2/4: COPY ./artifact.bin /bin/webservice
--> Using cache d48b76170004a6bb0965e8905ddfe75671cb706346500b37028210a1e713ce41
--> d48b76170004
STEP 3/4: ENV HOST 0.0.0.0
--> Using cache 224047d0ec48afdb18cc4e2bd2c4954b5edd0388ed5a6d6557eca2efbb9646d5
--> 224047d0ec48
STEP 4/4: ENTRYPOINT [ "/bin/webservice" ]
--> Using cache a4f6895e9c9bd6135b6fc2b1e4ba8bc43a54472e1812b3dbc960933d43e9d7cd
COMMIT webservice:latest
--> a4f6895e9c9b
Successfully tagged localhost/webservice:latest
Successfully tagged localhost/my-webservice:1.0.0
142d3985417ec0a72f6d625d78727277cc6c12cc9bdfe4322a719004f7f88410
lucad@lucad:~/Documents/DevOps/tutorials/webservice/build images & start containers$ podman run --publish 80
80:3000 --name my-container my-webservice:1.0.0
a4f6895e9c9bd6135b6fc2b1e4ba8bc43a54472e1812b3dbc960933d43e9d7cd
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman run --publish 8080:3000 --name test webservice:latest
Error: creating container storage: the container name "test" is already in use by b9fa9a215008866f64125849976eabae6fce83433f09685899a7898733654641. You have to remove that container to be able to reuse that name: that name is already in use, or use --replace to instruct Podman to do so.
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman run --publish 8080:3000 --name webserver-container webservice:latest
2024/09/02 14:53:21 Starting application...
time=2024-09-02T14:53:21.710Z level=INFO msg="Using ephemeral store"
2024/09/02 14:53:21 Configuration loaded: &{Version:n/a FontColor: LogLevel:debug Environment:development Host:0.0.0.0 Port:3000 DatabaseHost: DatabasePort:6379 DatabaseName:0 DatabaseUsername: DatabasePassword:}
time=2024-09-02T14:53:21.710Z level=INFO msg="Starting server on 0.0.0.0:3000"
┌───────────────────────────────────────────────────┐
│ webservice │
│ Fiber v2.51.0
│ Fiber v2.52.5
│ http://127.0.0.1:3000 │
│ (bound on host 0.0.0.0 and port 3000) │
│ │
│ Handlers ............ 27 Processes ........... 1 │
│ Handlers ............ 31 Processes ........... 1 │
│ Prefork ....... Disabled PID ................. 1 │
└───────────────────────────────────────────────────┘
time=2024-06-06T08:59:03.480Z level=DEBUG msg="GET / mime:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 agent:Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"
time=2024-06-06T08:59:04.146Z level=DEBUG msg="GET /favicon.ico mime:image/avif,image/webp,*/* agent:Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"
time=2024-06-06T08:59:28.837Z level=DEBUG msg="GET / mime:*/* agent:curl/8.2.1"
^Ctime=2024-06-06T08:59:50.647Z level=INFO msg="Gracefully shutting down HTTP server"
lucad@lucad:~/Documents/DevOps/tutorials/webservice/build images & start containers$
Guest Terminal:
lucad@lucad:~$ curl http://0.0.0.0:8080
Hello, World!lucad@lucad:~$
AWS CLI:
lucad@lucad:~$ aws --version
aws-cli/2.15.40 Python/3.11.8 Linux/6.5.0-35-generic exe/x86_64.ubuntu.23 prompt/off
lucad@lucad:~$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************ODY5 shared-credentials-file
secret_key ****************1ec3 shared-credentials-file
region us-east-1 config-file ~/.aws/config
lucad@lucad:~$ aws configure
AWS Access Key ID [****************ODY5]:
AWS Secret Access Key [****************1ec3]:
Default region name [us-east-1]:
Default output format [None]:
lucad@lucad:~$ sudo aws s3 mb s3://test-bucket-$(date +%s)
make_bucket failed: s3://test-bucket-1718627187 An error occurred (InvalidAccessKeyId) when calling the CreateBucket operation: The AWS Access Key Id you provided does not exist in our records.
lucad@lucad:~$ aws s3 mb s3://test-bucket-$(date +%s)
make_bucket: test-bucket-1718627205
lucad@lucad:~$ aws s3 ls
2024-06-17 14:26:48 test-bucket-1718627205
^Ctime=2024-09-02T14:53:42.888Z level=INFO msg="HTTP-Server wird ordnungsgemäß heruntergefahren"
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman run --publish 8080:3000 -rm --name webserver-container -d webservice:latest
Error: unknown shorthand flag: 'r' in -rm
See 'podman run --help'
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman run --publish 8080:3000 --rm --name webserver-container -d webservice:latest
Error: creating container storage: the container name "webserver-container" is already in use by 816358d9051b3892064310cb077261f895c53311c7922216f938d302f4bc1238. You have to remove that container to be able to reuse that name: that name is already in use, or use --replace to instruct Podman to do so.
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman run --publish 8080:3000 --rm --name webserver-cont -d webservice:latest
9531b2801c03ea704dfe946bed58cf67404560cc2b4a3020a6556ac0dcff16d9
lucad@lucad:~/Documents/webservice/build_images_start_containers$ curl http://localhost:8080
Hello, World!lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9531b2801c03 localhost/webservice:latest About a minute ago Up About a minute 0.0.0.0:8080->3000/tcp webserver-cont
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman stop 816358d9051b3892064310cb077261f895c53311c7922216f938d302f4bc1238
816358d9051b3892064310cb077261f895c53311c7922216f938d302f4bc1238
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9531b2801c03 localhost/webservice:latest About a minute ago Up About a minute 0.0.0.0:8080->3000/tcp webserver-cont
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman stop 9531b2801c03
9531b2801c03
lucad@lucad:~/Documents/webservice/build_images_start_containers$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
lucad@lucad:~/Documents/webservice/build_images_start_containers$
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment