Skip to content

Commit 0dae8eb

Browse files
author
Igor Ushakov
committed
CI\CD for docker added + build to local
1 parent c9e7c7d commit 0dae8eb

File tree

4 files changed

+63
-23
lines changed

4 files changed

+63
-23
lines changed

.github/workflows/docker.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Docker Image Build and Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "*.*.*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-latest
12+
environment: cli_docker
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
18+
- name: Build
19+
uses: docker/build-push-action@v5
20+
with:
21+
context: .
22+
file: docker/Dockerfile
23+
push: false
24+
tags: passwork-cli:test
25+
outputs: type=docker
26+
27+
- name: Tests
28+
run: |
29+
docker run --rm passwork-cli:test --help
30+
31+
- name: Login
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKER_USERNAME }}
35+
password: ${{ secrets.DOCKER_PASSWORD }}
36+
37+
- name: Push
38+
run: |
39+
docker tag passwork-cli:test ${{ secrets.DOCKER_USERNAME }}/passwork-cli:latest
40+
docker tag passwork-cli:test ${{ secrets.DOCKER_USERNAME }}/passwork-cli:${{ github.ref_name }}
41+
docker push ${{ secrets.DOCKER_USERNAME }}/passwork-cli:latest
42+
docker push ${{ secrets.DOCKER_USERNAME }}/passwork-cli:${{ github.ref_name }}

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A Python client for interacting with the Passwork password management API. It pr
44

55
## Installation
66

7-
You can install the package directly from Bitbucket:
7+
You can install the package directly from Github:
88

99
```bash
1010
pip install git+ssh://[email protected]:passwork-me/passwork-python.git
@@ -56,9 +56,12 @@ For detailed CLI documentation and examples, see the [CLI README](cli/README.md)
5656
For CI/CD pipelines and containerized environments, a Docker image is provided:
5757

5858
```bash
59-
# Build the Docker image
60-
cd docker
61-
docker build -t passwork-cli .
59+
# Pull the Docker image
60+
docker pull passwork/passwork-cli:latest
61+
docker tag passwork/passwork-cli:latest passwork-cli
62+
63+
# Or build it yourself
64+
docker build -f docker/Dockerfile -t passwork-cli .
6265

6366
# Run a command using the container
6467
docker run -it --rm \
@@ -258,4 +261,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
258261
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
259262
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
260263
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
261-
SOFTWARE.
264+
SOFTWARE.

docker/Dockerfile

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
FROM python:3.11-slim
1+
FROM python:3.11-slim AS builder
2+
WORKDIR /app
3+
COPY . .
4+
RUN pip install --prefix=/install --no-cache-dir .
25

6+
FROM python:3.11-slim
37
LABEL maintainer="Passwork Team"
48
LABEL description="Passwork CLI Docker Image for CI/CD pipelines"
59

6-
# Install git and other dependencies
7-
RUN apt-get update && \
8-
apt-get install -y --no-install-recommends git && \
9-
apt-get clean && \
10-
rm -rf /var/lib/apt/lists/*
10+
COPY --from=builder /install /usr/local
1111

12-
# Set working directory
13-
WORKDIR /app
14-
15-
# Install passwork-cli
16-
RUN pip install --no-cache-dir git+https://github.com/passwork-me/passwork-python.git
12+
RUN groupadd -r passwork --gid=1001 && \
13+
useradd -r -g passwork --uid=1001 passwork
1714

18-
# Create a non-root user to run the CLI
19-
RUN groupadd -r passwork && useradd -r -g passwork passwork
2015
USER passwork
21-
22-
# Set the entrypoint to passwork-cli
2316
ENTRYPOINT ["passwork-cli"]
2417
CMD ["--help"]

docker/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
[![Docker Pulls](https://img.shields.io/docker/pulls/passwork/passwork-cli)](https://hub.docker.com/r/passwork/passwork-cli) [![Image Size](https://img.shields.io/docker/image-size/passwork/passwork-cli/latest)](https://hub.docker.com/r/passwork/passwork-cli) ![Docker Build](https://github.com/passwork-me/passwork-python/actions/workflows/docker.yaml/badge.svg)
2+
13
# Passwork CLI Docker Container
24

35
This directory contains Docker configuration for running Passwork CLI in a containerized environment, which is particularly useful for CI/CD pipelines in Bitbucket or other CI systems.
46

57
## Building the Docker Image
68

79
```bash
8-
cd docker
9-
docker build -t passwork-cli .
10+
docker build -f ../docker/Dockerfile -t passwork-cli ..
1011
```
1112

1213
## Using the Docker Container
@@ -97,6 +98,7 @@ pipelines:
9798
```
9899
99100
Don't forget to set up repository variables in Bitbucket:
101+
100102
- `PASSWORK_HOST`
101103
- `PASSWORK_TOKEN`
102104
- `PASSWORK_MASTER_KEY`
@@ -105,4 +107,4 @@ Don't forget to set up repository variables in Bitbucket:
105107

106108
- The Docker image runs as a non-root user for improved security
107109
- Always use secure environment variables in CI/CD pipelines for your credentials
108-
- Consider using refresh tokens for long-running pipelines
110+
- Consider using refresh tokens for long-running pipelines

0 commit comments

Comments
 (0)